【发布时间】:2021-05-25 18:35:13
【问题描述】:
cy.get('body'). then(body => {
cy.wrap(body).should('have.class','.layout-header')
}
cypress 没有找到“layout-header”类。当我这样做时,它就会起作用:
cy.get('body'). then(body => {
cy.get('.layout-header')
}
我需要这个,因为我想使用这样的条件测试:
cy.get('body').then(($body) => {
// synchronously ask for the body's text
// and do something based on whether it includes
// another string
if ($body.text().includes('some string')) {
// yup found it
cy.get(...).should(...)
} else {
// nope not here
cy.get(...).should(...)
}
}) 你能告诉我为什么吗?谢谢
【问题讨论】:
标签: testing conditional-statements cypress