Test Overview
This test uses cy.wait() to pause the test for a fixed time before clicking a button and verifying the result. It checks that the button click updates the page text as expected.
This test uses cy.wait() to pause the test for a fixed time before clicking a button and verifying the result. It checks that the button click updates the page text as expected.
describe('Explicit wait with cy.wait()', () => { it('waits before clicking and verifies text update', () => { cy.visit('https://example.cypress.io/commands/waiting') cy.wait(2000) // wait 2 seconds explicitly cy.get('.wait-btn').click() cy.get('.wait-message').should('contain', 'Button clicked!') }) })
| 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/commands/waiting' | Page loads with button labeled 'Wait Button' and empty message area | - | PASS |
| 3 | Explicitly wait for 2000 milliseconds using cy.wait(2000) | Page remains unchanged, test pauses for 2 seconds | - | PASS |
| 4 | Find element with class '.wait-btn' and click it | Button is found and clicked, triggering message update | - | PASS |
| 5 | Find element with class '.wait-message' and check it contains text 'Button clicked!' | Message area now shows 'Button clicked!' | Verify text content includes 'Button clicked!' | PASS |