Bird
0
0

Which of the following is the correct Cypress syntax to assert that a button has an attribute disabled?

easy📝 assertion Q12 of 15
Cypress - Assertions
Which of the following is the correct Cypress syntax to assert that a button has an attribute disabled?
Acy.get('button').should('have.attr', 'disabled')
Bcy.get('button').should('have.value', 'disabled')
Ccy.get('button').should('contain', 'disabled')
Dcy.get('button').should('be.disabled')
Step-by-Step Solution
Solution:
  1. Step 1: Identify attribute assertion syntax

    The correct way to check for an attribute presence is using should('have.attr', 'attributeName').
  2. Step 2: Match the attribute name

    Here, the attribute is 'disabled', so the command is should('have.attr', 'disabled').
  3. Final Answer:

    cy.get('button').should('have.attr', 'disabled') -> Option A
  4. Quick Check:

    Attribute assertion uses 'have.attr' [OK]
Quick Trick: Use 'have.attr' to check attribute presence [OK]
Common Mistakes:
  • Using 'have.value' instead of 'have.attr' for attributes
  • Using 'contain' which checks text content, not attributes
  • Confusing 'be.disabled' which checks element state, not attribute

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Cypress Quizzes