【发布时间】:2021-07-23 07:10:51
【问题描述】:
在我的代码中,如果有图像被成功删除,但是当画布中有多个图像时,我怎么知道我必须调用 Remove_image() 函数多少次? 我的条件是如果 body 发现 canvas 为 null 然后上传图片,否则删除上传的图片。
这是我的代码
cy.get('body').each((body) => {
if (body.find(':nth-child(2) > .front-upload > :nth-child(2) > .table > .table-cell').length > 0) {
const filepath = "Front.jpg"
imageupload.fileuploadInput().attachFile(filepath, { subjectType: 'drag-n-drop' })
cy.wait(60000)
cy.Flip_image()
}
else {
// REMOVE ELEMENT
cy.log('Remove Image')
// There is 5 uploaded image that's why this function call 5 times But this is not right structure.
cy.Remove_image()
cy.Remove_image()
cy.Remove_image()
cy.Remove_image()
cy.Remove_image()
// UPLOAD IMAGE
cy.wait(1000)
const filepath = "Front.jpg"
imageupload.fileuploadInput().attachFile(filepath, { subjectType: 'drag-n-drop' })
cy.wait(60000)
cy.Flip_image()
}
})
【问题讨论】:
-
如果你在这里做一个sn-p,我们可以更好地帮助你
标签: javascript jquery cypress