Test Overview
This test checks that a login button with a data-cy attribute can be found and clicked reliably. It verifies that using data-cy attributes helps keep tests stable even if other page elements change.
This test checks that a login button with a data-cy attribute can be found and clicked reliably. It verifies that using data-cy attributes helps keep tests stable even if other page elements change.
describe('Login Button Test', () => { it('should find and click the login button using data-cy attribute', () => { cy.visit('https://example.com/login'); cy.get('[data-cy="login-button"]').click(); cy.url().should('include', '/dashboard'); }); });
| Step | Action | System State | Assertion | Result |
|---|---|---|---|---|
| 1 | Test starts | Cypress test runner initialized | - | PASS |
| 2 | Browser opens and navigates to https://example.com/login | Login page is loaded with login button having data-cy='login-button' | - | PASS |
| 3 | Find element with selector [data-cy=login-button] | Login button element is found using data-cy attribute | Element exists and is visible | PASS |
| 4 | Click the login button | Login button is clicked, triggering navigation | - | PASS |
| 5 | Check that URL includes '/dashboard' after click | Browser navigated to dashboard page | URL contains '/dashboard' | PASS |