Bird
0
0

You wrote this Cypress test:

medium📝 Debug Q14 of 15
Cypress - Assertions
You wrote this Cypress test:
cy.get('.popup').should('not.exist')

But the test fails even though the popup is hidden. What is the likely problem?
AThe selector '.popup' is incorrect.
BThe popup element exists but is hidden, so 'not.exist' fails.
CThe test should use 'should('not.be.visible')' instead.
DCypress cannot check hidden elements.
Step-by-Step Solution
Solution:
  1. Step 1: Understand difference between 'not.exist' and hidden elements

    'not.exist' fails if element is present in DOM, even if hidden.
  2. Step 2: Apply to the popup element

    The popup is hidden but still in DOM, so assertion fails because element exists.
  3. Final Answer:

    The popup element exists but is hidden, so 'not.exist' fails. -> Option B
  4. Quick Check:

    'not.exist' means element absent, hidden still exists [OK]
Quick Trick: Hidden elements still exist; use 'not.be.visible' for hidden check [OK]
Common Mistakes:
  • Using 'not.exist' to check hidden elements
  • Assuming hidden means not in DOM
  • Ignoring difference between visibility and existence

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Cypress Quizzes