Bird
0
0

Which Cypress assertion verifies that an element is visible to the user on the page?

easy📝 Conceptual Q1 of 15
Cypress - Assertions
Which Cypress assertion verifies that an element is visible to the user on the page?
Ashould('exist')
Bshould('be.visible')
Cshould('have.text')
Dshould('be.enabled')
Step-by-Step Solution
Solution:
  1. Step 1: Understand visibility assertion

    The assertion should('be.visible') checks if the element is visible on the page, meaning it is not hidden or covered.
  2. Step 2: Compare with other assertions

    should('exist') checks presence in DOM but not visibility; should('have.text') checks text content; should('be.enabled') checks if element is enabled.
  3. Final Answer:

    should('be.visible') -> Option B
  4. Quick Check:

    Visibility assertion = should('be.visible') [OK]
Quick Trick: Use should('be.visible') to check if element is shown [OK]
Common Mistakes:
  • Confusing 'exist' with 'be.visible'
  • Using 'have.text' to check visibility
  • Assuming 'be.enabled' means visible

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Cypress Quizzes