Navigate back or forward to the previous or next URL in the browser’s history.
cy.go(direction) cy.go(direction, options)
direction (String, Number)
The direction to navigate.
You can use
forward to go one step back or forward. You could also navigate to a specific history position (
-1 goes back one page,
1 goes forward one page, etc).
Pass in an options object to change the default behavior of
||Displays the command in the Command log|
||Time to wait for
windowobject after the page finishes loading.
cy.go('back') // equivalent to clicking back button
cy.go('forward') // equivalent to clicking forward button
cy.go(-1) // equivalent to clicking back button
cy.go(1) // equivalent to clicking forward button
If going forward or back causes a full page refresh, Cypress will wait for the new page to load before moving on to new commands.
Cypress additionally handles situations where a page load was not caused (such as hash routing) and will resolve immediately.
cy.go()requires being chained off of
cy.go()requires the response to be
cy.go()requires the response code to be
2xxafter following redirects.
cy.go()requires the load
loadevent to eventually fire.
cy.go()will automatically wait for assertions you've chained to pass.
cy.go()can time out waiting for the page to fire its
cy.go()can time out waiting for assertions you've added to pass.
Go back in browser’s history
cy .visit('http://localhost:8000/folders') .go('back')
The commands above will display in the Command Log as:
When clicking on the
go command within the command log, the console outputs the following: