Bird
0
0

Consider this Cypress code snippet:

medium📝 Predict Output Q13 of 15
Cypress - Assertions
Consider this Cypress code snippet:
cy.get('input#email')
  .should('have.attr', 'placeholder', 'Enter your email')
  .and('have.value', '')

What will this test verify?
AThe input has placeholder text 'Enter your email' and is empty.
BThe input has value 'Enter your email' and placeholder is empty.
CThe input is visible and enabled for typing.
DThe input has attribute 'value' set to 'Enter your email'.
Step-by-Step Solution
Solution:
  1. Step 1: Analyze the attribute assertion

    should('have.attr', 'placeholder', 'Enter your email') checks the placeholder attribute equals 'Enter your email'.
  2. Step 2: Analyze the value assertion

    and('have.value', '') asserts the input's current value is empty (no text typed).
  3. Final Answer:

    The input has placeholder text 'Enter your email' and is empty. -> Option A
  4. Quick Check:

    Attribute + value assertions combined = The input has placeholder text 'Enter your email' and is empty. [OK]
Quick Trick: Attribute checks attribute text; value checks input content [OK]
Common Mistakes:
  • Mixing placeholder attribute with input value
  • Assuming value is placeholder text
  • Ignoring the empty string value assertion

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Cypress Quizzes