2.23 Playwright QA Pipeline Setup Guide
Playwright is a robot that tests your website by actually clicking buttons, filling forms, and checking if everything works — just like a human would. Instead of manually clicking through your app after every code change, Playwright does it automatically in seconds, catching bugs before they reach production.
Playwright is a robot that tests your website by actually clicking buttons, filling forms, and checking if everything works — just like a human would. Instead of manually clicking through your app after every code change, Playwright does it automatically in seconds, catching bugs before they reach production.
End-to-end browser automation testing with Playwright — how to set up, write, run, and integrate automated QA tests into CI/CD pipelines for the RAIA (Real estate Artificial Intelligence Agent) platform.
Section A What Is Playwright QA?
Playwright is Microsoft's modern browser automation framework. It controls real browsers (Chrome, Firefox, Safari) programmatically, clicking elements, typing text, and verifying behavior — exactly like a human tester would, but automated and fast.
Why Automated Testing?
Manual testing doesn't scale. Every feature branch would require a human clicking through 20+ workflows to verify nothing broke. Playwright automates this:
- Takes 30+ minutes per build
- Humans forget edge cases
- Inconsistent between testers
- Can't run at 2am when CI builds
- Runs in 2-5 minutes
- Never forgets a test case
- Perfectly consistent
- Runs 24/7 on every commit
Section B Installation
Install Playwright in your Next.js or Node.js project:
# Install Playwright and browsers npm init playwright@latest # Or add to existing project npm install -D @playwright/test npx playwright install
The npx playwright install command downloads Chromium, Firefox, and WebKit (~500MB total). This is normal and required for local testing.
Writing Tests
Create a test file in tests/example.spec.ts:
import { test, expect } from '@playwright/test';
test('homepage loads and shows RAIA (Real estate Artificial Intelligence Agent) branding', async ({ page }) => {
// Navigate to homepage
await page.goto('https://portal.estateaigents.com');
// Check title
await expect(page).toHaveTitle(/RAIA/);
// Check logo is visible
await expect(page.locator('img[alt="RAIA (Real estate Artificial Intelligence Agent) Logo"]')).toBeVisible();
});
test('login flow with valid credentials', async ({ page }) => {
await page.goto('https://portal.estateaigents.com/login');
// Fill login form
await page.fill('input[name="email"]', 'test@example.com');
await page.fill('input[name="password"]', 'SecurePassword123');
await page.click('button[type="submit"]');
// Wait for redirect to dashboard
await expect(page).toHaveURL(/dashboard/);
await expect(page.locator('h1')).toContainText('Dashboard');
});
Running Tests
Execute tests locally or in CI:
# Run all tests (headless) npx playwright test # Run in headed mode (see browser) npx playwright test --headed # Run specific test file npx playwright test tests/login.spec.ts # Debug mode (pause execution) npx playwright test --debug # Generate HTML report npx playwright show-report
CI Integration
Add Playwright to GitHub Actions:
name: Playwright Tests
on:
push:
branches: [main, develop]
pull_request:
branches: [main]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '20'
- name: Install dependencies
run: npm ci
- name: Install Playwright browsers
run: npx playwright install --with-deps
- name: Run Playwright tests
run: npx playwright test
- name: Upload test report
if: always()
uses: actions/upload-artifact@v4
with:
name: playwright-report
path: playwright-report/
Use npx playwright install --with-deps in CI to install system libraries (like libglib). Without --with-deps, browsers will fail to launch on fresh CI containers.
Section C Architecture
Test Patterns
Follow these patterns for maintainable, reliable tests:
| Pattern | Bad Example | Good Example |
|---|---|---|
| Locators | page.locator('.btn-primary') |
page.locator('button[data-testid="submit"]') |
| Waits | await page.waitForTimeout(3000) |
await page.locator('#result').waitFor() |
| Assertions | if (await page.locator('#msg').isVisible()) |
await expect(page.locator('#msg')).toBeVisible() |
| Cleanup | Leave sessions hanging | Use test.afterEach to logout/clear storage |
Troubleshooting
If tests randomly fail with "element not found", you're clicking before the page finishes loading. Use await page.waitForLoadState('networkidle') or wait for specific elements instead of timeouts.
In CI, browser launch can timeout if system dependencies are missing. Always use npx playwright install --with-deps to install OS-level libraries.
Advanced Techniques
Page Object Model (POM) — encapsulate page interactions:
// pages/LoginPage.ts
export class LoginPage {
constructor(private page: Page) {}
async login(email: string, password: string) {
await this.page.fill('input[name="email"]', email);
await this.page.fill('input[name="password"]', password);
await this.page.click('button[type="submit"]');
}
}
// tests/login.spec.ts
import { LoginPage } from '../pages/LoginPage';
test('login with POM', async ({ page }) => {
const loginPage = new LoginPage(page);
await loginPage.login('test@example.com', 'password123');
await expect(page).toHaveURL(/dashboard/);
});
Visual Regression Testing — catch UI changes:
test('homepage visual snapshot', async ({ page }) => {
await page.goto('https://portal.estateaigents.com');
await expect(page).toHaveScreenshot('homepage.png');
});
Never rely on production data in tests. Use test.beforeEach to seed a test database or use API mocks. Tests must be deterministic and repeatable.