Cypress test: is .contains() equivalent to should(‘contain’)?

The result on your cypress test will be the same if the element with name=planSelect does not contain dummyPlan, that is, the test will fail at this point. The difference between them is that in the first form, using contains(), you’re actually trying to select an element, and the result of cy.get(…).contains() will yield this … Read more

Cypress: How to know if element is visible or not in using If condition?

Cypress allows jQuery to work with DOM elements so this will work for you: cy.get(“selector_for_your_button”).then($button => { if ($button.is(‘:visible’)){ //you get here only if button is visible } }) UPDATE: You need to differentiate between button existing and button being visible. The code below differentiates between 3 various scenarios (exists & visible, exists & not … Read more