Playwright

From seaworld008/Commonly-used-high-value-skills · View interactive version

Playwright is an AI agent skill from the GitHub repository seaworld008/Commonly-used-high-value-skills. Use when the task requires automating a real browser from the terminal (navigation, form filling, snapshots, screenshots, data extraction, UI-flow debugging) via `playwright-cli` or the bundled wrapper script.

How to use this skill

Skill file

Playwright CLI Skill

Drive a real browser using an already available, supported playwright-cli or

host browser capability. Match the commands and documentation to that version.

Treat this skill as CLI-first automation. Do not pivot to @playwright/test unless the user explicitly asks for test files.

Capability Discovery

@playwright/cli and @playwright/mcp are different packages and interfaces.

The reviewed Playwright MCP release is 0.0.86 (Node.js >= 20 required); it does not

establish the CLI's version or command support. When driving @playwright/mcp 0.0.86+:

extension tab-group sessions support --session-name / --session-color, browser_close

closes the entire browser and all tabs (use browser_tabs with action: "close" to close

a single tab), downloads preserve collision-safe filenames, and Linux ARM64 Chrome installs

via npx @playwright/mcp@0.0.86 install-browser chrome. Native Browser/Chrome plugins use

their host's current tools and lifecycle documentation. Keep refs and session handles within

the chosen backend instead of translating them by name.

Check the project's installed CLI and the host's browser tools before choosing

an execution path. Missing npx alone is not a reason to stop all work. If a

dependency must be acquired, reuse existing installation authorization, choose

a compatible fixed version and an isolated local runner; do not install globally

as a loading side effect. Without browser capability, complete independent static

work and state which browser acceptance checks were not run.

Skill path (set once)

PWCLI="/absolute/path/to/verified/installed/playwright-cli"

Resolve PWCLI from the selected installed CLI; keep host environment variables

unchanged. Resolve any bundled helper from the actual loaded skill directory.

Quick start

Use the verified installed CLI selected above:

"$PWCLI" open https://playwright.dev --headed
"$PWCLI" snapshot
"$PWCLI" click e15
"$PWCLI" type "Playwright"
"$PWCLI" press Enter
"$PWCLI" screenshot

Use only commands supported by that CLI version. Installation, if necessary,

is a separate scoped dependency change under existing authorization.

Core workflow

  1. Open the page.
  2. Snapshot to get stable element refs.
  3. Interact using refs from the latest snapshot.
  4. Re-snapshot after navigation or significant DOM changes.
  5. Capture artifacts (screenshot, pdf, traces) when useful.

Minimal loop:

"$PWCLI" open https://example.com
"$PWCLI" snapshot
"$PWCLI" click e3
"$PWCLI" snapshot

When to snapshot again

Snapshot again after:

Refs can go stale. When a command fails due to a missing ref, snapshot again.

Recommended patterns

Form fill and submit

"$PWCLI" open https://example.com/form
"$PWCLI" snapshot
"$PWCLI" fill e1 "user@example.com"
"$PWCLI" fill e2 "password123"
"$PWCLI" click e3
"$PWCLI" snapshot

Debug a UI flow with traces

"$PWCLI" open https://example.com --headed
"$PWCLI" tracing-start
# ...interactions...
"$PWCLI" tracing-stop

Multi-tab work

"$PWCLI" tab-new https://example.com
"$PWCLI" tab-list
"$PWCLI" tab-select 0
"$PWCLI" snapshot

Wrapper script

The bundled scripts/playwright_cli.sh actually executes

npx --yes --package @playwright/cli playwright-cli: it may download an unpinned

package even for --help. It preserves explicit --session or injects

PLAYWRIGHT_CLI_SESSION, but does not enforce a fixed dependency version.

Use an existing verified CLI directly; use a separately pinned local invocation

only when acquisition is authorized. Do not treat the wrapper as an offline or

version-locked runner. For the selected CLI:

"$PWCLI" --help

Keep the session and fresh-snapshot loop with the selected supported runner.

References

Open only what you need:

Guardrails

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.