Bird
0
0

Which of the following is the correct syntax to select an element with a custom attribute data-test='submit-btn' in Cypress?

easy📝 Syntax Q12 of 15
Cypress - Selecting Elements
Which of the following is the correct syntax to select an element with a custom attribute data-test='submit-btn' in Cypress?
Acy.get('[data-test=submit-btn]')
Bcy.get('data-test=submit-btn')
Ccy.get('#submit-btn')
Dcy.get('.submit-btn')
Step-by-Step Solution
Solution:
  1. Step 1: Recall attribute selector syntax

    In CSS selectors, attributes are selected with square brackets and quotes if needed.
  2. Step 2: Match correct Cypress syntax

    cy.get('[data-test=submit-btn]') correctly uses attribute selector syntax.
  3. Final Answer:

    cy.get('[data-test=submit-btn]') -> Option A
  4. Quick Check:

    Attribute selectors use brackets [] [OK]
Quick Trick: Use brackets [] around attribute selectors in cy.get() [OK]
Common Mistakes:
  • Omitting brackets for attribute selectors
  • Using ID or class selectors incorrectly
  • Missing quotes around attribute values

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Cypress Quizzes