赛普拉斯断言 A 或 B
Cypress assert A or B
我想在Cypress中做一个断言如下:
cy.get(a).should('be.visible').or(()=>{
cy.get(b).should('be.visible');
});
换句话说,我想检查条件A或条件B是否为真。如何在赛普拉斯中做到这一点?
一种方法是使用 jQuery multiple selector. It will require moving the visible
assertion inside the the selector using :visible。
cy.get('a:visible, b:visible')
请注意,您牺牲了赛普拉斯的一些 built-in 重试(与所有条件测试一样)。
例如,如果现在 b:visible
但 1 秒后 a:visible
,它将给你 b
。而 cy.get(a).should('be.visible')
将等待第二个 return a
.
根据场景的具体情况,还有其他方式。
我想在Cypress中做一个断言如下:
cy.get(a).should('be.visible').or(()=>{
cy.get(b).should('be.visible');
});
换句话说,我想检查条件A或条件B是否为真。如何在赛普拉斯中做到这一点?
一种方法是使用 jQuery multiple selector. It will require moving the visible
assertion inside the the selector using :visible。
cy.get('a:visible, b:visible')
请注意,您牺牲了赛普拉斯的一些 built-in 重试(与所有条件测试一样)。
例如,如果现在 b:visible
但 1 秒后 a:visible
,它将给你 b
。而 cy.get(a).should('be.visible')
将等待第二个 return a
.
根据场景的具体情况,还有其他方式。