Test Overview
This test generates a unique username dynamically and verifies that the registration form accepts it successfully.
This test generates a unique username dynamically and verifies that the registration form accepts it successfully.
describe('User Registration with Dynamic Data', () => { it('should register a user with a unique username', () => { const uniqueUsername = `user_${Date.now()}`; cy.visit('https://example.com/register'); cy.get('#username').type(uniqueUsername); cy.get('#email').type(`${uniqueUsername}@mail.com`); cy.get('#password').type('Password123!'); cy.get('#register-btn').click(); cy.get('.success-message').should('contain.text', 'Registration successful'); }); });
| 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/register' | Registration page is loaded with username, email, password fields and register button | Page URL is correct and form elements are visible | PASS |
| 3 | Generates a unique username using current timestamp | Variable uniqueUsername holds a string like 'user_1687000000000' | uniqueUsername is a non-empty string with expected format | PASS |
| 4 | Finds username input field and types the unique username | Username input contains the unique username text | Input value matches uniqueUsername | PASS |
| 5 | Finds email input field and types email based on unique username | Email input contains text like 'user_1687000000000@mail.com' | Input value matches generated email | PASS |
| 6 | Finds password input field and types 'Password123!' | Password input contains the typed password | Input value matches 'Password123!' | PASS |
| 7 | Finds and clicks the register button | Form is submitted, page processes registration | - | PASS |
| 8 | Checks for success message containing 'Registration successful' | Success message is visible on the page | Success message text contains 'Registration successful' | PASS |