← Back to library
Cypresswaitadvancedv10+
Wait for URL to change after an action
Assert the URL after a button click or form submit — Cypress retries cy.url() automatically for SPA navigation.
1it('URL advances on each step of the onboarding flow', () => {
2 cy.visit('/onboarding/step-1');
3
4 cy.get('[name="company"]').type('Acme Corp');
5 cy.get('[type="submit"]').click();
6
7 // cy.url() retries — no explicit wait needed for most client-side navigations
8 cy.url().should('include', '/onboarding/step-2');
9 cy.get('h1').should('contain.text', 'Step 2');
10
11 cy.get('[type="submit"]').click();
12
13 // For slower SPAs, extend the timeout on the assertion
14 cy.url({ timeout: 10_000 }).should('include', '/onboarding/step-3');
15});#url#navigation#SPA#redirect#timeout