Test Overview
This test uses the cypress-real-events plugin to simulate a native click event on a button. It verifies that the button's click handler is triggered and the expected text appears on the page.
This test uses the cypress-real-events plugin to simulate a native click event on a button. It verifies that the button's click handler is triggered and the expected text appears on the page.
import 'cypress-real-events/support'; describe('Native click event test with cypress-real-events', () => { it('should trigger native click and show confirmation text', () => { cy.visit('https://example.cypress.io/commands/actions'); cy.get('.action-btn').realClick(); cy.get('.action-btn').should('have.class', 'clicked'); cy.get('#action-callback').should('contain.text', 'Button clicked'); }); });
| Step | Action | System State | Assertion | Result |
|---|---|---|---|---|
| 1 | Test starts | Cypress test runner is ready | - | PASS |
| 2 | Browser opens and navigates to https://example.cypress.io/commands/actions | Page with action buttons is loaded | Page URL is correct | PASS |
| 3 | Find element with class '.action-btn' | Button element is visible and enabled | Element exists and is visible | PASS |
| 4 | Perform native click on the button using realClick() | Button receives native click event | - | PASS |
| 5 | Check if button has class 'clicked' after click | Button class list updated to include 'clicked' | Button has class 'clicked' | PASS |
| 6 | Check if element with id '#action-callback' contains text 'Button clicked' | Confirmation text is displayed on page | Text 'Button clicked' is present | PASS |