Bird
0
0

Consider this code snippet:

medium📝 Predict Output Q5 of 15
Cypress - Assertions
Consider this code snippet:
cy.get('input').should('have.attr', 'placeholder').and('contain', 'Email')

What does this assertion check?
AThe input has a placeholder attribute and contains the text 'Email'
BThe input has a placeholder attribute exactly equal to 'Email'
CThe input contains the text 'Email' inside it
DThe input is visible and has a placeholder attribute
Step-by-Step Solution
Solution:
  1. Step 1: Understand have.attr and contain chaining

    The first assertion checks the presence of the attribute, the second checks if the element contains 'Email'.
  2. Step 2: Interpret the chained assertions

    It confirms the placeholder attribute exists and the element contains the text 'Email'.
  3. Final Answer:

    The input has a placeholder attribute and contains the text 'Email' -> Option A
  4. Quick Check:

    have.attr + contain checks attribute presence + element text [OK]
Quick Trick: Chain have.attr and contain to check attribute presence and element text [OK]
Common Mistakes:
  • Assuming exact match instead of substring
  • Confusing attribute presence with element text
  • Ignoring chaining order and meaning

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Cypress Quizzes