playwright
Installation
SKILL.md
Playwright Browser Automation
Use this skill to drive a real browser with Playwright: author end-to-end tests, keep selectors and tests robust, intercept and mock network traffic, run suites across parallel workers and in CI, scrape and extract data in headless mode, and check accessibility with snapshot scans. This is a tool skill for one named tool. Test strategy and framework selection belong to qa-methodology; frontend component and architecture design belong to frontend-engineering. This skill owns operating the Playwright tool itself.
Operating contract
- Read the suite before running. Inspect
playwright.config.*, projects,baseURL,webServer, workers, retries, and reporters before running anything. Never assume the test command from the README. - Locate by behavior, not layout. Prefer user-facing locators (
getByRole,getByLabel,getByText) over CSS/XPath that encode markup. Tests coupled to user-visible behavior survive refactors; tests coupled to structure break on them. - Mock at the boundary. Stub external HTTP at
page.route()— never by patching in-page code. Mock the dependency under test's edges, never the code under test itself; a test that mocks what it claims to verify proves nothing. - Parallelize deliberately. Playwright gives every test an isolated browser context. Tune
workersand sharding to the machine and suite, and never let tests share mutable state through globals. - Verify at the boundary. A green test is only as strong as its assertions. Assert on user-visible outcomes (visible text, URL, enabled/disabled state), not on implementation details.
- Keep evidence bounded. Capture traces, screenshots, and video on failure only; summarize JSON reports instead of dumping them; never paste full HTML dumps or session cookies into chat.
The pwrun script
scripts/pwrun is an agent-first smoke harness around a Playwright suite. doctor, inventory, and report work with no node or Playwright installed, so an agent can inspect a suite and triage a CI report anywhere.