I want to be able to click on a check box and test that an element is no longer in the DOM in Cypress. Can someone suggest how you do it?
//This is the Test when the check box is clicked and the element is there cy.get('[type="checkbox"]').click(); cy.get('.check-box-sub-text').contains('Some text in this div.')
I want to do the opposite of the test above. So when I click it again the div with the class should not be in the DOM.
Well this seems to work, so it tells me I have some more to learn about .should()
cy.get('.check-box-sub-text').should('not.exist');
you can also search a for a text which is not supposed to exist:
cy.contains('[email protected]').should('not.exist')
Here you have the result in Cypress: 0 matched elements
documentation: https://docs.cypress.io/guides/references/assertions.html#Existence
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With