I want to make an assertion in Cypress as follows:
cy.get(a).should('be.visible').or(()=>{
cy.get(b).should('be.visible');
});
In other words, I want to check if condition A or condition B is true. How to do this in Cypress?
I want to make an assertion in Cypress as follows:
cy.get(a).should('be.visible').or(()=>{
cy.get(b).should('be.visible');
});
In other words, I want to check if condition A or condition B is true. How to do this in Cypress?
One way is to use the jQuery multiple selector. It will require moving the visible assertion inside the the selector using :visible.
cy.get('a:visible, b:visible')
Be aware you sacrifice some of Cypress' built-in retry (as with all conditional testing).
For example, if b:visible now but a:visible in 1 second, it will give you b. Whereas cy.get(a).should('be.visible') will wait the second and return a.
Depending on details of the scenario, there are other ways.