Bird
0
0

Which of the following is the correct Cypress command to select an element with id 'submit-btn'?

easy📝 Syntax Q3 of 15
Cypress - Selecting Elements
Which of the following is the correct Cypress command to select an element with id 'submit-btn'?
Acy.query('#submit-btn')
Bcy.find('.submit-btn')
Ccy.select('submit-btn')
Dcy.get('#submit-btn')
Step-by-Step Solution
Solution:
  1. Step 1: Recall Cypress syntax for selecting by id

    Use cy.get() with CSS selector syntax, id uses # prefix.
  2. Step 2: Validate options

    Only cy.get('#submit-btn') is correct syntax; others are invalid commands or wrong selectors.
  3. Final Answer:

    cy.get('#submit-btn') -> Option D
  4. Quick Check:

    Correct Cypress id selector = cy.get('#id') [OK]
Quick Trick: Use cy.get('#id') to select elements by id [OK]
Common Mistakes:
  • Using cy.find() without a parent element
  • Using cy.select() which is for dropdowns
  • Using cy.query() which is not a Cypress command

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Cypress Quizzes