Test Overview
This test opens a webpage, clicks a link, and verifies the URL changes as expected using cy.url() assertions.
This test opens a webpage, clicks a link, and verifies the URL changes as expected using cy.url() assertions.
describe('URL Assertion Test', () => { it('should navigate to Actions page and verify URL', () => { cy.visit('https://example.cypress.io') cy.get('a[href="/commands/actions"]').click() cy.url().should('include', '/commands/actions') cy.url().should('eq', 'https://example.cypress.io/commands/actions') }) })
| Step | Action | System State | Assertion | Result |
|---|---|---|---|---|
| 1 | Test starts | Test runner initialized, no browser opened yet | - | PASS |
| 2 | Browser opens and navigates to 'https://example.cypress.io' | Browser shows the Cypress example homepage | - | PASS |
| 3 | Finds link with href '/commands/actions' using cy.get | Link element is found on the page | - | PASS |
| 4 | Clicks the found link | Browser navigates to the Actions commands page | - | PASS |
| 5 | Asserts URL includes '/commands/actions' using cy.url().should('include', ...) | Current URL is 'https://example.cypress.io/commands/actions' | URL contains '/commands/actions' | PASS |
| 6 | Asserts URL equals 'https://example.cypress.io/commands/actions' using cy.url().should('eq', ...) | Current URL is exactly 'https://example.cypress.io/commands/actions' | URL equals 'https://example.cypress.io/commands/actions' | PASS |