← Back to library
Cypressnavigationintermediatev10+
Assert and interact after a redirect
Verify that a form submission or link triggers a redirect, then assert the landing page rendered correctly.
1it('redirects to dashboard after successful login', () => {
2 cy.visit('/login');
3
4 cy.get('[name="email"]').type('user@test.com');
5 cy.get('[name="password"]').type('secret');
6 cy.get('[type="submit"]').click();
7
8 // cy.url() retries automatically — handles async client-side redirects
9 cy.url().should('include', '/dashboard');
10
11 // Assert the landing page rendered correctly after the redirect
12 cy.get('[data-testid="welcome-banner"]').should('be.visible');
13 cy.get('[data-testid="user-menu"]').should('contain.text', 'user@test.com');
14});#redirect#navigation#url#login#landing page