Cypress · Junior · Question 21 of 75

How do you assert an element is NOT on the page?

Show the answer

Correct answer: .should('not.exist')

Explanation

not.exist passes when the query finds nothing. not.be.visible is different: the element exists but is hidden.

Further reading

Problem with a question

Cypress · Junior · question 21

Test yourself

Take the Cypress · Junior quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz