RAIA™ Specification

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.

← Back to Developer Hub TEXTBOOK SPECIFICATION
🟢 In Plain English

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.

Browser Automation E2E Testing CI/CD Ready Multi-Browser
3
Browsers supported — Chromium, Firefox, WebKit (Safari engine)
100%
Headless mode — runs in CI without a GUI, perfect for automation
< 5s
Typical test runtime — fast feedback loops during development
0
Flakiness tolerance — tests must be deterministic, no random failures

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.

1. Code Change Developer pushes to feature branch 2. CI Trigger GitHub Actions starts test run 3. Playwright Launches browsers Runs 50+ tests 4. Pass/Fail ✅ Merge OK ❌ Block PR Inside Playwright Test Run: Login Flow Type email + pwd Dashboard Check widgets Form Submit Create tenancy API Check Verify DB write Screenshot Visual regression Logout Clean session Code push → Automated tests → Pass/Fail verdict → Human review only if needed

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:

Manual Testing (Bad)
  • Takes 30+ minutes per build
  • Humans forget edge cases
  • Inconsistent between testers
  • Can't run at 2am when CI builds
Playwright (Good)
  • 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
💡
Browser Binaries Are Large

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/
🚨
Must Install System Dependencies in CI

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.


🔒 Developer-Only Section — Advanced Patterns & Troubleshooting

Section C Architecture

Playwright Test Runner Parallelization · Retries · Reporting · CI Integration Chromium Chrome / Edge Desktop + Mobile Firefox Mozilla Gecko Cross-browser WebKit Safari Engine Apple devices Page Objects & Test APIs Locators · Assertions · Actions (click, type, select) Auto-waiting · Screenshots · Network interception · Storage state Tests run in parallel → each browser isolated → results aggregated → HTML report

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

⚠️
Flaky Tests: Element Not Found

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.

⚠️
CI Failures: Browser Launch Timeout

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');
});
Best Practice: Test Data Isolation

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.

Repository Code

The live codebase implementation for this textbook logic sits within the following repository folder: