Real-World Examples 💡
Here are practical examples showing how HeedBase transforms your ideas into working Playwright tests:
E-commerce Testing
Guest Checkout Flow
Input: “Test guest checkout for a T-shirt purchase”
Generated Test:
test('Guest can purchase a T-shirt', async ({ page }) => {
await page.goto('https://demo-shop.heedbase.com');
await page.click('a:has-text("Men")');
await page.click('a:has-text("T-shirt")');
await page.click('button:has-text("Add to Cart")');
await page.click('button:has-text("Checkout")');
await page.fill('#email', 'guest@example.com');
await page.fill('#address', '123 Main St');
await page.click('button:has-text("Place Order")');
});Cart Functionality
Input: “Test adding multiple items to cart and updating quantities”
Generated Test:
test('Cart quantity updates', async ({ page }) => {
await page.goto('https://mystore.com');
// Add first item
await page.click('.product:first-child .add-to-cart');
// Add second item
await page.click('.product:nth-child(2) .add-to-cart');
// Update quantity
await page.click('.cart-icon');
await page.fill('.cart-item:first-child input[type="number"]', '3');
});Authentication Testing
Login Flow
Input: “Test user login with valid and invalid credentials”
Generated Test Scenarios:
test('successful login', async ({ page }) => {
await page.goto('https://myapp.com/login');
await page.fill('#email', 'user@example.com');
await page.fill('#password', 'password123');
await page.click('button[type="submit"]');
});
test('failed login with invalid password', async ({ page }) => {
await page.goto('https://myapp.com/login');
await page.fill('#email', 'user@example.com');
await page.fill('#password', 'wrongpassword');
await page.click('button[type="submit"]');
});Registration Flow
Input: “Test user registration with form validation”
Generated Test:
test('User registration with validation', async ({ page }) => {
await page.goto('https://myapp.com/register');
// Test empty form
await page.click('button[type="submit"]');
// Test invalid email
await page.fill('#email', 'invalid-email');
await page.click('button[type="submit"]');
// Test successful registration
await page.fill('#email', 'newuser@example.com');
await page.fill('#password', 'SecurePass123!');
await page.fill('#confirmPassword', 'SecurePass123!');
await page.click('button[type="submit"]');
});Form Testing
Contact Form
Input: “Test contact form validation and submission”
Generated Test:
test('Contact form validation', async ({ page }) => {
await page.goto('https://mywebsite.com/contact');
// Test empty form submission
await page.click('button[type="submit"]');
// Test valid submission
await page.fill('#name', 'John Doe');
await page.fill('#email', 'john@example.com');
await page.fill('#message', 'Hello, this is a test message');
await page.click('button[type="submit"]');
});Search Functionality
Input: “Test search with different query types”
Generated Test:
test('search with valid query', async ({ page }) => {
await page.goto('https://mystore.com');
await page.fill('#search-input', 'laptop');
await page.click('#search-button');
});
test('search with empty query', async ({ page }) => {
await page.goto('https://mystore.com');
await page.click('#search-button');
});
test('search with no results', async ({ page }) => {
await page.goto('https://mystore.com');
await page.fill('#search-input', 'nonexistentproduct123');
await page.click('#search-button');
});Navigation Testing
Menu Navigation
Input: “Test main navigation menu functionality”
Generated Test:
test('Main navigation menu', async ({ page }) => {
await page.goto('https://mywebsite.com');
// Test dropdown menu
await page.hover('.nav-item:has-text("Products")');
// Test menu links
await page.click('.nav-item:has-text("About")');
// Test mobile menu
await page.setViewportSize({ width: 375, height: 667 });
await page.click('.mobile-menu-toggle');
});Payment Testing
Payment Processing
Input: “Test payment flow with different card types”
Generated Test:
test('successful payment with Visa', async ({ page }) => {
await page.goto('https://mystore.com/checkout');
await page.fill('#card-number', '4111111111111111');
await page.fill('#expiry', '12/25');
await page.fill('#cvv', '123');
await page.click('#pay-button');
});
test('declined payment', async ({ page }) => {
await page.goto('https://mystore.com/checkout');
await page.fill('#card-number', '4000000000000002');
await page.fill('#expiry', '12/25');
await page.fill('#cvv', '123');
await page.click('#pay-button');
});Best Practices Examples
Test Organization
Input: “Create a test suite for user account management”
Generated Test Suite:
test('update profile information', async ({ page }) => {
await page.goto('https://myapp.com/login');
await page.fill('#email', 'test@example.com');
await page.fill('#password', 'password123');
await page.click('button[type="submit"]');
await page.click('.user-menu');
await page.click('a:has-text("Profile")');
await page.fill('#firstName', 'Updated Name');
await page.click('#save-button');
});
test('change password', async ({ page }) => {
await page.goto('https://myapp.com/login');
await page.fill('#email', 'test@example.com');
await page.fill('#password', 'password123');
await page.click('button[type="submit"]');
await page.click('.user-menu');
await page.click('a:has-text("Security")');
await page.fill('#currentPassword', 'password123');
await page.fill('#newPassword', 'newpassword123');
await page.fill('#confirmPassword', 'newpassword123');
await page.click('#change-password-button');
});Common Patterns
Basic Test Structure
Input: “Create reusable test structure for common elements”
Generated Test:
test('Login with basic structure', async ({ page }) => {
await page.goto('https://myapp.com/login');
await page.fill('#email', 'user@example.com');
await page.fill('#password', 'password123');
await page.click('button[type="submit"]');
});Tips for Better Examples
Be Specific
- Good: “Test the checkout process”
- Better: “Test guest checkout with credit card payment and order confirmation”
Include Edge Cases
- Test both success and failure scenarios
- Include validation testing
- Test with different data types
Use Real Data
- Use realistic test data
- Test with different user types
- Include various input formats
Next Steps
Have a cool use-case you’d like to share? Email support@heedbase.com!