Bird
0
0

What will happen when this Cypress code runs?

medium📝 Predict Output Q13 of 15
Cypress - Assertions
What will happen when this Cypress code runs?
cy.get('.message').should('contain.text', 'Success')
ATest passes if element with class 'message' contains text 'Success'
BTest fails if element with class 'message' contains text 'Success'
CTest passes regardless of element text
DTest throws a syntax error
Step-by-Step Solution
Solution:
  1. Step 1: Analyze the assertion syntax

    The code uses .should('contain.text', 'Success'), which is a valid Cypress assertion chainer.
  2. Step 2: Determine test outcome

    The test passes if the element with class 'message' contains the text 'Success'; otherwise, it fails.
  3. Final Answer:

    Test passes if element with class 'message' contains text 'Success' -> Option A
  4. Quick Check:

    Valid 'contain.text' assertion = A [OK]
Quick Trick: 'contain.text' is valid in Cypress for text content check [OK]
Common Mistakes:
  • Thinking 'contain.text' is invalid
  • Predicting pass/fail based on text presence
  • Confusing with other assertion methods

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Cypress Quizzes