Test Overview
This test uses the Page Object Model to separate page structure from test logic. It verifies that a user can log in successfully and see a welcome message.
This test uses the Page Object Model to separate page structure from test logic. It verifies that a user can log in successfully and see a welcome message.
class LoginPage { visit() { cy.visit('https://example.com/login') } fillUsername(name) { cy.get('#username').clear().type(name) } fillPassword(password) { cy.get('#password').clear().type(password) } submit() { cy.get('button[type="submit"]').click() } } describe('Login Test with POM', () => { const loginPage = new LoginPage() it('should log in successfully and show welcome message', () => { loginPage.visit() loginPage.fillUsername('testuser') loginPage.fillPassword('Password123') loginPage.submit() cy.get('#welcome-message').should('contain.text', 'Welcome, testuser!') }) })
| Step | Action | System State | Assertion | Result |
|---|---|---|---|---|
| 1 | Test starts | Cypress test runner initialized | - | PASS |
| 2 | Browser opens and navigates to 'https://example.com/login' | Login page is displayed with username and password fields | URL is 'https://example.com/login' | PASS |
| 3 | Finds username input field with selector '#username' and types 'testuser' | Username field contains 'testuser' | Username input value is 'testuser' | PASS |
| 4 | Finds password input field with selector '#password' and types 'Password123' | Password field contains 'Password123' | Password input value is 'Password123' | PASS |
| 5 | Finds submit button with selector 'button[type="submit"]' and clicks it | Form submitted, page processes login | - | PASS |
| 6 | Finds element with selector '#welcome-message' and checks it contains text 'Welcome, testuser!' | Welcome message is visible on the page | Text content includes 'Welcome, testuser!' | PASS |
| 7 | Test ends | Test completed successfully | - | PASS |