0
0
Cypresstesting~10 mins

cy.reload() in Cypress - Test Execution Trace

Choose your learning style9 modes available
Test Overview

This test verifies that the page reloads correctly using cy.reload() and that a specific element is visible after the reload.

Test Code - Cypress
Cypress
describe('Page reload test', () => {
  it('Reloads the page and checks element visibility', () => {
    cy.visit('https://example.cypress.io')
    cy.get('h1').should('be.visible')
    cy.reload()
    cy.get('h1').should('be.visible')
  })
})
Execution Trace - 5 Steps
StepActionSystem StateAssertionResult
1Test startsTest runner initialized, no browser actions yet-PASS
2Browser opens and navigates to 'https://example.cypress.io'Page loads with visible <h1> element-PASS
3Finds <h1> element<h1> element is present and visible on the pageCheck that <h1> is visiblePASS
4Calls cy.reload() to reload the pagePage reloads, content refreshes-PASS
5Finds <h1> element again after reload<h1> element is present and visible after reloadCheck that <h1> is visible after reloadPASS
Failure Scenario
Failing Condition: The <h1> element is not found or not visible after the page reloads
Execution Trace Quiz - 3 Questions
Test your understanding
What does cy.reload() do in this test?
AReloads the current page in the browser
BNavigates to a new URL
CClicks on the <h1> element
DWaits for the page to load without reloading
Key Result
Always verify key page elements after a reload to ensure the page refreshed correctly and content is intact.