Test Overview
This test navigates between two pages using Cypress commands and then uses cy.go() to move back and forward in the browser history. It verifies that the URL changes correctly after each navigation step.
This test navigates between two pages using Cypress commands and then uses cy.go() to move back and forward in the browser history. It verifies that the URL changes correctly after each navigation step.
describe('Test cy.go() browser history navigation', () => { it('should navigate back and forward in browser history', () => { cy.visit('https://example.cypress.io') cy.contains('type').click() cy.url().should('include', '/commands/actions') cy.go('back') cy.url().should('eq', 'https://example.cypress.io/') cy.go('forward') cy.url().should('include', '/commands/actions') }) })
| Step | Action | System State | Assertion | Result |
|---|---|---|---|---|
| 1 | Test starts | Browser is ready to open a page | - | PASS |
| 2 | cy.visit('https://example.cypress.io') | Browser opens https://example.cypress.io homepage | - | PASS |
| 3 | cy.contains('type').click() | Page navigates to the 'type' commands page | - | PASS |
| 4 | cy.url().should('include', '/commands/actions') | URL includes '/commands/actions' | Verify URL contains '/commands/actions' | PASS |
| 5 | cy.go('back') | Browser navigates back to the homepage | - | PASS |
| 6 | cy.url().should('eq', 'https://example.cypress.io/') | URL is exactly 'https://example.cypress.io/' | Verify URL equals homepage URL | PASS |
| 7 | cy.go('forward') | Browser navigates forward to the 'type' commands page | - | PASS |
| 8 | cy.url().should('include', '/commands/actions') | URL includes '/commands/actions' again | Verify URL contains '/commands/actions' after forward navigation | PASS |