Case study 01
Building a scalable web automation framework from scratch
Designing and building a Playwright and TypeScript framework focused on reliability, maintainability, test isolation and efficient execution in CI/CD.
Playwright · TypeScript · GitHub Actions · Docker · Qase · Claude Code
- 2.5×
- automated web coverage growth
- 60+ → <20 min
- regression execution time
- 7 → 20
- post-deployment smoke scenarios
- UI + API
- in one framework
The problem
Regression relied heavily on manual passes, and the automation that existed was hard to extend. Selectors were scattered across specs and tests shared accounts and data, so it was often unclear whether a failure meant a product bug or a problem with the suite.
The team needed a framework that new contributors could pick up easily, and that could grow without becoming much slower or less reliable.
What I did
1.Separate what a test checks from how it gets there
Page objects own locators and interactions; specs describe behaviour and hold all the assertions. When an existing element changes, the fix is usually in one page object rather than in every spec that uses it. Locators prefer test IDs and roles over CSS, so they're less likely to break when styling changes. Row lookups match the name cell exactly, so a project called "Site A" never matches "Site AB".
pages/projects.page.ts import type { Page, Locator } from "@playwright/test"; export class ProjectsPage { readonly newProjectButton: Locator; readonly projectNameInput: Locator; readonly createButton: Locator; readonly projectRows: Locator; constructor(private readonly page: Page) { this.newProjectButton = page.getByRole("button", { name: "New project" }); this.projectNameInput = page.getByLabel("Project name"); this.createButton = page.getByRole("button", { name: "Create" }); this.projectRows = page.getByTestId("project-row"); } async open() { await this.page.goto("/projects"); } async createProject(name: string) { await this.newProjectButton.click(); await this.projectNameInput.fill(name); await this.createButton.click(); } // Exact match on the name cell: no regex, no partial matches. projectRow(name: string): Locator { return this.projectRows.filter({ has: this.page.getByRole("cell", { name, exact: true }), }); } }2.Set up test data through the API
Creating data by clicking through the UI is slow, and it makes every test depend on screens it isn't testing. Fixtures create data through the API, hand the test a typed object, and delete the data in a finally block so cleanup runs even when the test fails. Names combine the worker index, the retry number and a random suffix, so parallel workers, retries and concurrent CI runs don't collide.
fixtures/index.ts import { test as base } from "@playwright/test"; import { randomUUID } from "node:crypto"; import { ApiClient } from "../api/client"; import { ProjectsPage } from "../pages/projects.page"; type Fixtures = { api: ApiClient; projectsPage: ProjectsPage; seededProject: { id: string; name: string }; }; export const test = base.extend<Fixtures>({ api: async ({ request }, use) => { await use(new ApiClient(request)); }, projectsPage: async ({ page }, use) => { await use(new ProjectsPage(page)); }, seededProject: async ({ api }, use, testInfo) => { // Unique across parallel workers, retries and concurrent CI runs. const name = `e2e-w${testInfo.workerIndex}-r${testInfo.retry}-${randomUUID().slice(0, 8)}`; const project = await api.createProject(name); try { await use(project); } finally { await api.deleteProject(project.id); } }, }); export { expect } from "@playwright/test";3.Specs that read like acceptance criteria
With setup in fixtures and mechanics in page objects, a spec is a few lines that product and design can review against the acceptance criteria. Assertions stay in the spec, so it's clear what each test checks.
tests/projects.spec.ts import { test, expect } from "../fixtures"; test("a renamed project keeps its history", async ({ projectsPage, seededProject, api }) => { const newName = `${seededProject.name} renamed`; await api.renameProject(seededProject.id, newName); await projectsPage.open(); await expect(projectsPage.projectRow(newName)).toBeVisible(); const history = await api.history(seededProject.id); expect(history.at(-1)?.event).toBe("project.renamed"); });4.AI-assisted test automation with human oversight
At Sitemate I built a Claude Code skill, create-automated-test, that turns a manual test case from our test management tool into a Playwright test that follows the framework's conventions. It reads the case and the existing specs, page objects and fixtures, checks every locator against the application source, and presents a plan. It writes code only after a person confirms the plan. Anything it can't confirm, such as a missing locator or missing test data, is left as a TODO for a person instead of being guessed. New tests run several times before review as a first check for flakiness. That doesn't prove a test is stable, so flaky tests found later are still triaged like any other defect. The excerpt below comes from a generic version I rewrote for my public portfolio. It contains none of Sitemate's code or conventions.
create-automated-test/SKILL.md (public portfolio version, excerpt) ## Rules while planning - Never skip a step. Each step is implemented, or the whole case is blocked. - "Any of A, B, C" means test all of them. No .first() standing in for a group. - A success message is not proof. If the result says "X appears in Y", go to Y and assert X. ## Locator verification A locator that can't be confirmed in the app source or a live page is never added. Leave "// TODO: locator not found" and list it in the report. Priority: data-test -> role with name -> text -> placeholder -> id or class. ## Code rules - Locators are readonly properties in the page object. None in specs. - Assertions in specs only. The test title is the case title, word for word. - No sleeps. Wait on a signal. Then type-check and run the new tests with --repeat-each=3.5.CI results drive release decisions
GitHub Actions runs the suite against each environment, posts a summary to Slack and sends results to Qase, so release decisions are based on a shared CI run rather than on results from someone's laptop. Running tests in Docker reduced differences between local and CI runs.
Outcome
- Web automation coverage grew 2.5×, and regression time dropped from over 60 minutes to under 20 (case study 03 explains how).
- Post-deployment smoke coverage went from 7 to 20 scenarios, run automatically after deploys.
- API and UI tests share one client and one set of fixtures, so security and permissions checks (authorisation, IDOR, data exposure) sit next to the UI flows they protect.
- With the conventions written into a skill, AI drafts new tests in the house style, and a person reviews the plan before any code is written.
Lessons learned
- Naming conventions, test IDs and a review checklist did more for maintainability than any clever abstraction.
- A flaky test points to a problem in either the product or the framework, so I triage it like any other defect.
Code samples are original demonstrations written for this site. They show the pattern, not any employer’s implementation.
Next case studyBuilding a cross-platform mobile automation framework →