Playwright

From theheavenlyd3mon/hermes-profiles · View interactive version

Playwright is an AI agent skill from the GitHub repository theheavenlyd3mon/hermes-profiles. Operate Playwright for browser automation end to end: author and debug E2E test suites (robust locators, network interception and mocking, parallel workers, accessibility snapshot checks), wire them into CI, and drive headless browsing and scraping with an extract -> validate -> save loop. Use when

How to use this skill

Skill file

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

  1. 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.
  2. 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.
  3. 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.
  4. Parallelize deliberately. Playwright gives every test an isolated browser context. Tune workers and sharding to the machine and suite, and never let tests share mutable state through globals.
  5. 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.
  6. 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.

scripts/pwrun doctor --json                     # node, @playwright/test, browsers, config availability
scripts/pwrun inventory --json                  # config, projects, spec files in the suite
scripts/pwrun report --report test-results.json --json   # summarize a Playwright JSON report
scripts/pwrun smoke --url http://localhost:3000 --json   # delegate a smoke run to npx playwright test

Exit codes: 0 ok, 1 analysis error, 2 usage error, 127 dependency (node/playwright) missing, 124 delegate timeout. --json on every command; --help works without any toolchain.

E2E test authoring

Selector robustness

Network interception and mocking

Parallel workers

CI integration

Scraping and headless browsing

Accessibility snapshot checks

Headed debugging

Reference routing

| Load when | Reference |

|---|---|

| Writing or structuring specs, fixtures, page objects | references/01-e2e-authoring.md |

| A selector is flaky or matches the wrong element | references/02-selectors.md |

| Mocking or intercepting API/network traffic | references/03-network-interception-and-mocking.md |

| Speeding up or sharding a large suite | references/04-parallel-workers-and-sharding.md |

| Wiring Playwright into CI or triaging CI failures | references/05-ci-integration.md |

| Extracting data or browsing in headless mode | references/06-scraping-and-headless.md |

| Accessibility scans, aria snapshots, or debugging a failing test | references/07-accessibility-and-debugging.md |

| Sources, version observations, and refresh procedure | references/00-source-index.md |

Included artifacts

Verification boundary

| Claim | Minimum evidence |

|---|---|

| Toolchain is present | scripts/pwrun doctor --json reports node, @playwright/test, and browsers available |

| Suite is understood | scripts/pwrun inventory --json lists config and spec files |

| A test passes | npx playwright test exit 0 on the targeted spec (or smoke delegation) |

| A CI failure is explained | scripts/pwrun report --report test-results.json --json names the failing specs and errors |

| Accessibility is covered | An axe scan runs with zero violations of the declared severity, and aria snapshots match |

| No regressions in the covered flows | The suite ran under the configured workers/sharding with expected/flaky/unexpected counts recorded |

Hard boundaries

When not to use

Topic coverage keywords

The catalog's automated topic sweep greps this file for coverage keywords. Two

alias pairs are written literally below so the sweep matches both spellings:

e2e|end-to-end covers browser-level tests (E2E, end-to-end, and e2e are the

same workflow), and debug|head covers the headed-debugging workflows in this

skill. All other topics (selector robustness, network interception, parallel

workers, CI integration, scraping, accessibility snapshots, mocking) appear by

name in the sections above.

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.