Bird
0
0

What does the Cypress command cy.get('.error').should('not.be.visible') verify?

easy📝 Conceptual Q1 of 15
Cypress - Assertions
What does the Cypress command cy.get('.error').should('not.be.visible') verify?
AThe element with class 'error' exists and is visible
BThe element with class 'error' is hidden or not visible on the page
CThe element with class 'error' does not exist in the DOM
DThe element with class 'error' is enabled and clickable
Step-by-Step Solution
Solution:
  1. Step 1: Understand the command context

    The command cy.get('.error') selects the element with class 'error'. The assertion should('not.be.visible') checks that this element is not visible on the page.
  2. Step 2: Interpret the assertion meaning

    The assertion does not check for existence but visibility. So the element can exist but must be hidden or invisible.
  3. Final Answer:

    The element with class 'error' is hidden or not visible on the page -> Option B
  4. Quick Check:

    Negative assertion on visibility = B [OK]
Quick Trick: Use 'not.be.visible' to check element is hidden [OK]
Common Mistakes:
  • Confusing 'not.be.visible' with 'not.exist'
  • Assuming element does not exist when it might be hidden
  • Mixing visibility with enabled/disabled state

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Cypress Quizzes