Examples of navigating to pages within your application in Cypress, for a full reference of commands, go to docs.cypress.io
To go back or forward in the browser's history, use the cy.go()
command.
cy.location().its('pathname').should('include', 'navigation')
// https://on.cypress.io/api/go
cy.go('back')
cy.location().its('pathname').should('not.include', 'navigation')
cy.go('forward')
cy.location().its('pathname').should('include', 'navigation')
// equivalent to clicking back
cy.go(-1)
cy.location().its('pathname').should('not.include', 'navigation')
// equivalent to clicking forward
cy.go(1)
cy.location().its('pathname').should('include', 'navigation')
To reload the page, use the cy.reload()
command.
cy.reload()
// reload the page without using the cache
cy.reload(true)
To visit a remote page, use the cy.visit()
command.
// Visit any sub-domain of your current domain
// Pass options to the visit
cy.visit('http://localhost:8080/commands/navigation', {
timeout: 50000, // increase total time for the visit to resolve
onBeforeLoad: function(contentWindow){
// contentWindow is the remote page's window object
},
onLoad: function(contentWindow){
// contentWindow is the remote page's window object
}
})