Test Overview
This test verifies that a checkbox can be checked and unchecked using Cypress commands cy.check() and cy.uncheck(). It confirms the checkbox state changes correctly.
This test verifies that a checkbox can be checked and unchecked using Cypress commands cy.check() and cy.uncheck(). It confirms the checkbox state changes correctly.
describe('Checkbox check and uncheck test', () => { it('should check and uncheck the checkbox', () => { cy.visit('https://example.com/form') cy.get('#subscribe-newsletter').check().should('be.checked') cy.get('#subscribe-newsletter').uncheck().should('not.be.checked') }) })
| 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.com/form' | Browser shows the form page with a checkbox having id 'subscribe-newsletter' | - | PASS |
| 3 | Find checkbox element with id 'subscribe-newsletter' using cy.get('#subscribe-newsletter') | Checkbox element is located on the page | - | PASS |
| 4 | Check the checkbox using cy.check() | Checkbox is now checked (ticked) | Verify checkbox is checked with .should('be.checked') | PASS |
| 5 | Find the same checkbox element again | Checkbox element is located and currently checked | - | PASS |
| 6 | Uncheck the checkbox using cy.uncheck() | Checkbox is now unchecked (unticked) | Verify checkbox is not checked with .should('not.be.checked') | PASS |