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 checkbox 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 check-box-sub-text
should not be in the DOM.
Use
.should('not.exist')
to assert that an element does not exist in the DOM.Do not use
not.visible
assertion. It would falsely pass in < 6.0, but properly fail now:Migration Docs here: Migrating-to-Cypress-6-0