Bird
0
0

Consider this Cypress test snippet:

medium📝 Predict Output Q13 of 15
Cypress - Navigation and URL
Consider this Cypress test snippet:
cy.visit('/home')
cy.get('#refresh-btn').click()
cy.reload()
cy.get('.welcome-message').should('be.visible')

What is the expected behavior after cy.reload() is called?
AThe page reloads and the test checks if '.welcome-message' is visible
BThe page reloads but the test fails because '.welcome-message' disappears
CThe page does not reload and the test checks the button click only
DThe test throws a syntax error at cy.reload()
Step-by-Step Solution
Solution:
  1. Step 1: Understand the test flow

    The test visits '/home', clicks a button, then reloads the page with cy.reload().
  2. Step 2: Analyze the assertion after reload

    After reload, the test checks if '.welcome-message' is visible. Assuming the page loads correctly, this element should be visible.
  3. Final Answer:

    The page reloads and the test checks if '.welcome-message' is visible -> Option A
  4. Quick Check:

    Reload refreshes page, then check element visibility = D [OK]
Quick Trick: Reload refreshes page; elements reappear if present [OK]
Common Mistakes:
  • Assuming reload removes elements permanently
  • Thinking reload causes syntax errors
  • Ignoring page reload effect on elements

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Cypress Quizzes