Bird
0
0

Which of the following is the correct Cypress syntax to assert that an element with id submitBtn is visible?

easy📝 assertion Q12 of 15
Cypress - Assertions
Which of the following is the correct Cypress syntax to assert that an element with id submitBtn is visible?
Acy.get('#submitBtn').should('exist')
Bcy.get('#submitBtn').should('contain', 'Submit')
Ccy.get('#submitBtn').should('be.visible')
Dcy.get('#submitBtn').should('have.text', 'Submit')
Step-by-Step Solution
Solution:
  1. Step 1: Identify the assertion for visibility

    The assertion should('be.visible') checks if the element is visible on the page.
  2. Step 2: Match syntax with element selector

    cy.get('#submitBtn') selects the element by id. Combining with should('be.visible') is correct syntax to check visibility.
  3. Final Answer:

    cy.get('#submitBtn').should('be.visible') -> Option C
  4. Quick Check:

    Visible check = should('be.visible') [OK]
Quick Trick: Use should('be.visible') to check if element shows on page [OK]
Common Mistakes:
  • Using 'exist' instead of 'be.visible' for visibility
  • Confusing 'have.text' with visibility check
  • Using 'contain' without 'text' for exact text check

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Cypress Quizzes