โ† Browse

@lexler/playwright-cli

A

Drive a browser from the terminal with playwright-cli: snapshot the page, then act on elements by ref. Use when automating browser interactions, filling web forms, testing UIs, or driving logged-in web apps from the command line.

skillclaude

Install

agr install @lexler/playwright-cli --target claude

Writes 1 file into .claude/skills/, pinned to git-85e7a440.

  • .claude/skills/playwright-cli/SKILL.md

Document


name: playwright-cli description: "Drive a browser from the terminal with playwright-cli: snapshot the page, then act on elements by ref. Use when automating browser interactions, filling web forms, testing UIs, or driving logged-in web apps from the command line."

STARTER_CHARACTER = ๐ŸŽญ

playwright-cli

Driving a browser from the shell. Each command prints the executed Playwright code, the page state, and a fresh snapshot.

The loop

Snapshot to see the page, act on an element by its ref, snapshot again.

playwright-cli snapshot          # accessibility tree with [ref=e8] handles
playwright-cli click e8          # act on a ref
playwright-cli snapshot          # confirm the result

Refs are not stable. Any DOM change renumbers them โ€” re-snapshot before acting on a page that just changed. Acting on a stale ref hits the wrong element or none.

For a large page, snapshot a region instead of the whole tree: snapshot e34 or snapshot --depth=4.

Targeting elements

A target is one of three things โ€” a ref, a CSS selector, or a Playwright locator:

playwright-cli click e8
playwright-cli click ".todo-list .toggle"
playwright-cli click "getByRole('button', { name: 'Submit' })"
playwright-cli click "getByText('buy milk')"

A bare descriptive phrase is not a target. click "the submit button" is parsed as a CSS selector and fails with "does not match any elements". Prefer refs; reach for getByRole/getByText when a ref won't survive a re-render.

Key commands

playwright-cli goto https://example.com
playwright-cli fill e5 "user@example.com" --submit   # clear, type, then Enter โ€” one step
playwright-cli type "free text into the focused element"
playwright-cli press Enter                            # also: Tab, Escape, ArrowDown
playwright-cli select e9 "option-value"
playwright-cli check e12        # uncheck / hover / dblclick likewise
playwright-cli screenshot       # saves to .playwright-cli/

fill works on React/controlled inputs where raw DOM events don't. After filling, the field must blur before dependent values (totals, validation) update โ€” --submit or a following press Tab does that.

Inspecting and verifying

playwright-cli eval "el => el.getAttribute('data-testid')" e5   # attributes the snapshot hides
playwright-cli console                                          # page console messages
playwright-cli requests                                         # network log, then `request <n>`

--raw strips the wrapper so output pipes, and proves what an action changed:

playwright-cli --raw snapshot > before.yml
playwright-cli click e8
playwright-cli --raw snapshot > after.yml
diff before.yml after.yml

Sessions

open launches a fresh browser; --persistent keeps cookies across runs. To drive an already-running, logged-in browser instead, attach over CDP. See references/attaching-to-chrome.md.

Name parallel browsers with -s=<name> (omit it for the implicit default session). playwright-cli list, close, close-all.

Full command set

The above is the working subset. The CLI ships its own exhaustive reference โ€” tabs, storage, mocking, tracing, video, codegen. See references/full-command-reference.md.

Trustgrade A

  • passBody integrity

    Whether the stored document is plausibly the kind of file the artifact declares, rather than something fetched by mistake.

  • passType matchnot applicable to this artifact type

    Whether the artifact is really the kind of thing its metadata claims it is.

  • passFreshness

    How long since the source repository was last pushed to.

  • passPrompt injection

    Scans the artifact's own text for instructions aimed at your agent rather than at you.

  • passLicense

    Whether the source repository declares an SPDX license permissive enough to redistribute.

How the grade is calculated

Each check contributes 0 points when it passes, 1 when it warns, and 2 when it fails. The total maps to a letter:

  • Aevery check passed
  • Bone warning
  • Ctwo warnings
  • Dprompt injection or body integrity failed, or three warnings
  • Fone of those failed, and something else is wrong

These are automated hygiene checks, not a security audit, and not a dependency or vulnerability scan. A grade of A means nothing was flagged โ€” not that the artifact is safe.

Versions

  • git-85e7a440f6112026-07-31