Test Overview
This test demonstrates how Cypress automatically retries commands until the element appears or the assertion passes. It verifies that a button becomes visible after a delay and can be clicked successfully.
This test demonstrates how Cypress automatically retries commands until the element appears or the assertion passes. It verifies that a button becomes visible after a delay and can be clicked successfully.
describe('Retry-ability of commands', () => { it('should wait for the button to appear and click it', () => { cy.visit('https://example.cypress.io/commands/waiting') // The button appears after 3 seconds cy.get('#delayed-button', { timeout: 5000 }) .should('be.visible') .click() cy.get('#delayed-button').should('have.class', 'clicked') }) })
| Step | Action | System State | Assertion | Result |
|---|---|---|---|---|
| 1 | Test starts | Test runner initialized, browser ready | - | PASS |
| 2 | Browser opens and navigates to 'https://example.cypress.io/commands/waiting' | Page loads with delayed button not yet visible | - | PASS |
| 3 | Cypress tries to find element with selector '#delayed-button' with 5 seconds timeout | Button not visible initially, appears after 3 seconds | Waits and retries until '#delayed-button' is found and visible | PASS |
| 4 | Cypress asserts '#delayed-button' is visible | Button is visible on the page | Check that button is visible | PASS |
| 5 | Cypress clicks the '#delayed-button' | Button is clicked, changes state | - | PASS |
| 6 | Cypress asserts '#delayed-button' has class 'clicked' | Button has class 'clicked' after click | Verify button state changed after click | PASS |