Test Overview
This test checks that a button on a webpage can be found and clicked using Cypress. It verifies that selecting the correct element is essential to interact with it successfully.
This test checks that a button on a webpage can be found and clicked using Cypress. It verifies that selecting the correct element is essential to interact with it successfully.
describe('Button click test', () => { it('should find and click the submit button', () => { cy.visit('https://example.com') cy.get('#submit-btn').click() cy.get('#message').should('contain', 'Success') }) })
| Step | Action | System State | Assertion | Result |
|---|---|---|---|---|
| 1 | Test starts | Cypress test runner is ready | - | PASS |
| 2 | Browser opens and navigates to https://example.com | Page loads with a submit button and message area | - | PASS |
| 3 | Find element with id 'submit-btn' using cy.get('#submit-btn') | Submit button element is located | Element with id 'submit-btn' exists | PASS |
| 4 | Click the submit button using .click() | Button is clicked, triggering page action | - | PASS |
| 5 | Find element with id 'message' and check it contains text 'Success' | Message element shows 'Success' text | Assert message contains 'Success' | PASS |