writing-playwright-tests

writing-playwright-tests is a skill for Claude Code from FortiumPartners/ensemble. It costs 38 tokens per session (2,717 once invoked), scanned A, original, MIT.

A guide for writing end-to-end browser tests with Playwright, a tool that controls a web browser for testing. It covers selectors, page objects, and waiting for legacy applications to respond.

In plain words
What is it for?
It is for adding or improving browser tests, including testing older applications and choosing stable ways to find page elements.
Why use it?
It helps tests avoid fragile references to changing page structure and reduces timing-related failures.

Skill for Claude Code

Written for Claude Code: shipped in a Claude Code plugin.

Needs its repository: it reads a path above its own folder, which exists only inside the repository. The line is import { ContactsPage } from '../pages/contacts.page';.

Part of the ensemble-e2e-testing plugin — 7 skills, 1 agent shipped together

Good fit It is for adding or improving browser tests, including testing older applications and choosing stable ways to find page elements.

Compare 6 skills from other repositories ↓
Install

Getting it into your agent

It runs from inside its repository, so the clone comes first — what it calls does not travel with the file alone.

Clone the repo
git clone --depth 1 https://github.com/FortiumPartners/ensemble
agentmods
npx agentmods add skills/fortiumpartners/ensemble/writing-playwright-tests

Made for: Claude Code.

Or install ensemble-e2e-testing, the plugin that ships this one along with the rest of its 7 skills, 1 agent.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for writing-playwright-tests

README.md
[![agentmods](https://agentmods.dev/badge/skills/fortiumpartners/ensemble/writing-playwright-tests/github.svg)](https://agentmods.dev/skills/fortiumpartners/ensemble/writing-playwright-tests)
Your own site
<a href="https://agentmods.dev/skills/fortiumpartners/ensemble/writing-playwright-tests"><img src="https://agentmods.dev/badge/skills/fortiumpartners/ensemble/writing-playwright-tests/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for writing-playwright-tests

Your own site · 80×15
<a href="https://agentmods.dev/skills/fortiumpartners/ensemble/writing-playwright-tests"><img src="https://agentmods.dev/badge/skills/fortiumpartners/ensemble/writing-playwright-tests.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 38 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 2,717 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00038 $0.02717
Opus 5 $0.00019 $0.01358
Sonnet 5 $0.00008 $0.00543
Haiku 4.5 $0.00004 $0.00272

Measured 6d ago against content hash a5cf9d7a3c78, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-09, from the pricing page.

Security

Grade A, and why

writing-playwright-tests scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 6d ago.

The scan reads SKILL.md. This mod also ships 13 executable files (examples/authentication-flow.example.ts, examples/data-table-crud.example.ts, examples/form-validation.example.ts, …), listed below but not scanned — reading those needs a real analyzer, not pattern matching.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

packages/e2e-testing/skills/writing-playwright-tests/SKILL.md · 457 lines

How it starts

The opening of the file, as written. The whole thing — 457 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Playwright E2E Testing Skill

1. Selector Strategy Hierarchy

Use selectors in this priority order for maximum resilience:

// BEST: Explicit test identifiers
page.getByTestId('submit-button')

// GOOD: Semantic role-based (accessible)
page.getByRole('button', { name: 'Submit' })
page.getByRole('heading', { level: 1 })
page.getByRole('textbox', { name: 'Email' })

// GOOD: User-visible text
page.getByText('Welcome back')
page.getByLabel('Email address')
page.getByPlaceholder('Enter your email')

// ACCEPTABLE: When above options unavailable
page.locator('[data-cy="element"]')  // Cypress migration
page.locator('#unique-id')            // Stable IDs only

// AVOID: Brittle structural selectors
page.locator('.btn-primary')          // Classes change
page.locator('div > span:nth-child(2)') // Structure changes
page.locator('//div[@class="foo"]')   // XPath fragile

Adding Test IDs to Legacy Apps

When retrofitting, add data-testid attributes incrementally:

<!-- Before: Relies on brittle class selector -->
<button class="btn btn-primary submit-form">Submit</button>

<!-- After: Resilient test identifier -->
<button class="btn btn-primary submit-form" data-testid="contact-form-submit">Submit</button>

Naming convention for test IDs:

{component}-{element}-{qualifier}
contact-form-submit
user-list-row-{id}
modal-confirm-button
nav-menu-toggle

2. Page Object Model

Basic Page Object

// pages/login.page.ts
import { Page, Locator } from '@playwright/test';

export class LoginPage {
  readonly page: Page;
  readonly emailInput: Locator;
  readonly passwordInput: Locator;
  readonly submitButton: Locator;
  readonly errorMessage: Locator;

  constructor(page: Page) {
    this.page = page;
    this.emailInput = page.getByLabel('Email');
    this.passwordInput = page.getByLabel('Password');
    this.submitButton = page.getByRole('button', { name: 'Sign in' });
    this.errorMessage = page.getByRole('alert');
  }

  async goto() {
    await this.page.goto('/login');
  }

  async login(email: string, password: string) {
    await this.emailInput.fill(email);
    await this.passwordInput.fill(password);
    await this.submitButton.click();
  }

  async expectError(message: string) {
    await expect(this.errorMessage).toContainText(message);
  }
}

Read the full file on GitHub · 457 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 6d ago First seen · 457 lines · 38 tokens per session scan A a5cf9d7a3c78

Subscribe to this mod's changes

writing-playwright-tests is a skill published in the GitHub repository FortiumPartners/ensemble (12 stars, last pushed yesterday), licensed MIT. It adds 38 tokens to every session and 2,717 once invoked, about $0.0002 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-09-03.

Related

Other skills, from other repositories

webapp-testing

Start/reuse a local app, wait for readiness, inspect rendered state/console/network, act from observed selectors, and verify with evidence.

Hmbown/CodeWhale · 32 tokens

playwright-cli

Automates browser interactions for web testing, form filling, screenshots, and data extraction. Use when the user needs to navigate websites, interact with web pages, fill forms, take screenshots, test web applications, or extract information from web pages.

VoltAgent/voltagent · 52 tokens

agent-browser

Use the host-side agent-browser CLI for local browser smoke tests, screenshots, snapshots, and simple UI validation against forwarded localhost URLs.

superagent-ai/grok-cli · 31 tokens

BrowserBash Browser Automation

BrowserBash is a vendor-independent, natural-language browser automation CLI. Drive a real browser from plain-English objectives or committable Markdown tests, run on local Chrome, CDP/Playwright MCP, Browserbase, LambdaTest, or BrowserStack, and stream NDJSON results with CI exit codes — using free local Ollama…

PramodDutta/qaskills · 79 tokens

e2e

Generate and run Playwright E2E tests traced to spec.md acceptance criteria, with an optional accessibility audit. Use when saying "e2e tests" or "a11y audit".

anton-abyzov/specweave · 38 tokens

test-app

Verify a running Mendix app in a browser with Playwright, with OQL for data assertions. Use when asked to test or validate the app end to end, or to confirm that generated pages actually render.

mendixlabs/mxcli · 45 tokens