cypress.io
  • Commands
    • Querying
    • Traversal
    • Actions
    • Window
    • Viewport
    • Location
    • Navigation
    • Assertions
    • Misc
    • Connectors
    • Aliasing
    • Waiting
    • Network Requests
    • Files
    • Storage
    • Cookies
    • Spies, Stubs & Clocks
  • Utilities
  • Cypress API
  • GitHub

Navigation

Examples of navigating to pages within your application in Cypress, for a full reference of commands, go to docs.cypress.io

cy.go()

To go back or forward in the browser's history, use the cy.go() command.

cy.location('pathname').should('include', 'navigation')

cy.go('back')
cy.location('pathname').should('not.include', 'navigation')

cy.go('forward')
cy.location('pathname').should('include', 'navigation')

// clicking back
cy.go(-1)
cy.location('pathname').should('not.include', 'navigation')

// clicking forward
cy.go(1)
cy.location('pathname').should('include', 'navigation')

cy.reload()

To reload the page, use the cy.reload() command.

cy.reload()

// reload the page without using the cache
cy.reload(true)

cy.visit()

To visit a remote page, use the cy.visit() command.

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
  }
})