Cypress: Contains

The html bellow does not render neither Hello nor World visually. But it does show in the page source.

<div style="display: none">Hello</div>
<div style="visibility: hidden">World</div>

Using this assertion will pass the test.

cy.contains("Hello")
cy.contains("World")

Using this assertion will NOT pass the test.

cy.contains("Hello").should("be.visible")
cy.contains("World").should("be.visible")

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *