【发布时间】:2019-08-18 04:51:01
【问题描述】:
我必须处理对话框元素,如果元素存在做某事而不做其他事情,但是 cy.get('...') CypressError: Timed out retrying, 导致有时元素不存在。如何处理
我试过 cy.get('...').find('...')、cy.get('...').then() 和 cy.get('...') .should('to.exist') 它不起作用。
cy.get('div.ui-dialog-content.ui-widget-content > p-messages > div > ul > li:nth-child(2) > span')
.should('to.exist').then(() => {
// only do if found element
cy.get('div.ui-dialog-titlebar.ui-widget-header.ui-helper-clearfix > a > span')
.click()
})
// do another
期望:如果对话框显示关闭它并继续测试,如果对话框不显示则正常测试
【问题讨论】:
标签: cypress