Bird
0
0

You want to verify a checkbox with id agree is checked after clicking it. Which assertion correctly verifies this expected behavior?

hard📝 Application Q15 of 15
Cypress - Assertions
You want to verify a checkbox with id agree is checked after clicking it. Which assertion correctly verifies this expected behavior?
Acy.get('#agree').click().should('have.value', 'checked')
Bcy.get('#agree').click().should('be.checked')
Ccy.get('#agree').click().should('contain.text', 'checked')
Dcy.get('#agree').click().should('be.visible')
Step-by-Step Solution
Solution:
  1. Step 1: Understand the goal of the assertion

    We want to confirm the checkbox is checked after clicking it.
  2. Step 2: Identify the correct assertion method

    The correct assertion is should('be.checked') which verifies checkbox state.
  3. Step 3: Evaluate options

    cy.get('#agree').click().should('be.checked') uses be.checked, which is correct. The other options incorrectly check value, visibility, or text content.
  4. Final Answer:

    cy.get('#agree').click().should('be.checked') -> Option B
  5. Quick Check:

    should('be.checked') = D [OK]
Quick Trick: Use .should('be.checked') to confirm checkbox is selected [OK]
Common Mistakes:
  • Checking visibility instead of checked state
  • Looking for text 'checked' inside checkbox
  • Using value instead of checked property

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Cypress Quizzes