reload

End-to-End Only

Reload the page.

Syntax

cy.reload()
cy.reload(forceReload)
cy.reload(options)
cy.reload(forceReload, options)

Usage

Correct Usage

cy.reload()

Arguments

forceReload (Boolean)

Whether to reload the current page without using the cache. true forces the reload without cache.

options (Object)

OptionDefaultDescription
logtrueDisplays the command in the Command log
timeoutpageLoadTimeoutTime to wait for cy.reload() to resolve before timing out Note: Network requests are limited by the underlying operating system, and may still time out if this value is increased.

Yields

  • cy.reload() 'yields the window object after the page finishes loading'

Examples

No Args

Reload the page as if the user clicked 'Refresh'

cy.visit('http://localhost:3000/admin')
cy.get('#undo-btn').click().should('not.be.visible')
cy.reload()
cy.get('#undo-btn').click().should('not.be.visible')

Force Reload

Reload the page without using the cache

cy.visit('http://localhost:3000/admin')
cy.reload(true)

Rules

Requirements

  • cy.reload() requires being chained off of cy .
  • cy.reload() requires the response to be content-type: text/html .
  • cy.reload() requires the response code to be 2xx after following redirects.
  • cy.reload() requires the load load event to eventually fire.

Assertions

  • cy.reload() will automatically wait for assertions you have chained to pass

Timeouts

  • cy.reload() can time out waiting for the page to fire its load event.
  • cy.reload() can time out waiting for assertions you've added to pass.

Command Log

Reload the page

cy.reload()

The commands above will display in the Command Log as:

Command Log reload

When clicking on reload within the command log, the console outputs the following:

Console Log reload

See also