Test Overview
This test opens a webpage, finds a button using a CSS selector with cy.get(), clicks it, and verifies the button's text changes as expected.
This test opens a webpage, finds a button using a CSS selector with cy.get(), clicks it, and verifies the button's text changes as expected.
describe('Button click test', () => { it('finds button by CSS selector and verifies text change', () => { cy.visit('https://example.cypress.io') cy.get('button.btn-primary').click() cy.get('button.btn-primary').should('have.text', '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' | Browser shows the example Cypress page | - | PASS |
| 3 | Finds button element with CSS selector 'button.btn-primary' using cy.get() | Button with class 'btn-primary' is visible on the page | Element found successfully | PASS |
| 4 | Clicks the found button | Button is clicked, page updates button text | - | PASS |
| 5 | Finds the same button again with cy.get('button.btn-primary') | Button is visible with updated text | Element found successfully | PASS |
| 6 | Asserts the button text is 'Clicked!' using .should('have.text', 'Clicked!') | Button text is 'Clicked!' | Button text equals 'Clicked!' | PASS |