Bird
0
0

What is wrong with this Cypress test code?

medium📝 Debug Q7 of 15
Cypress - Navigation and URL
What is wrong with this Cypress test code?
cy.visit('/page1')
cy.go('backward')
A'backward' is not a valid argument for cy.go()
Bcy.visit() must be called twice before cy.go()
Ccy.go() cannot be used with string arguments
Dcy.go() requires a callback function
Step-by-Step Solution
Solution:
  1. Step 1: Check valid string arguments for cy.go()

    Valid string arguments are 'back' and 'forward'. 'backward' is invalid.
  2. Step 2: Verify other options

    cy.visit() can be called once, cy.go() accepts string arguments, and it does not require a callback.
  3. Final Answer:

    'backward' is not a valid argument for cy.go() -> Option A
  4. Quick Check:

    Valid cy.go() strings: 'back', 'forward' only [OK]
Quick Trick: Use only 'back' or 'forward' strings with cy.go() [OK]
Common Mistakes:
  • Using 'backward' instead of 'back'
  • Thinking cy.go() needs callbacks
  • Believing cy.visit() must be called multiple times

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Cypress Quizzes