run-playwright

Use skill if you are controlling a live browser with @anthropic-ai/playwright-cli for navigation, forms, screenshots, tab workflows, or interactive debugging from the terminal.

Safety Notice

This listing is imported from skills.sh public index metadata. Review upstream SKILL.md and repository scripts before running.

Copy this and send it to your AI assistant to learn

Install skill "run-playwright" with this command: npx skills add yigitkonur/skills-by-yigitkonur/yigitkonur-skills-by-yigitkonur-run-playwright

Playwright CLI

Use @anthropic-ai/playwright-cli to drive a live browser from the terminal. Keep this file focused on trigger logic, workflow, guardrails, and reference routing. Use references/ for detailed commands, edge cases, and larger patterns.

Invocation model — read this first. Every command below (snapshot, click e0, fill e1 "text", etc.) is typed at the playwright-cli interactive prompt, not as standalone shell commands. You launch playwright-cli from bash, then enter commands at its > prompt. Do not prefix them with playwright-cli inside the session.

Trigger boundary

Use this skill when the task requires a real browser session and interactive CLI control:

  • open pages, navigate, and verify what actually rendered
  • fill forms, upload files, submit flows, and prove the result
  • manage tabs, popups, or session state during a live run
  • collect screenshots, console logs, network logs, or traces as evidence
  • use short run-code snippets only when the CLI lacks a direct command

Do not use this skill when:

  • the job is writing or reviewing Playwright test code instead of driving the CLI
  • plain HTTP fetching or static scraping is enough
  • the site needs Browserbase-style hosted browsing, anti-bot bypass, or remote browser routing; prefer run-agent-browser

Non-negotiable rules

  1. Prefer the current browser context when it already has the right state. Do not reset sessions or reinstall tools just because a browser exists.
  2. Prefer a new tab over a new window. Use a popup or new window only when the site forces one, such as OAuth or target=_blank flows.
  3. Keep a running tab map in your notes: index -> purpose -> expected URL/state. Refresh it after every tab-new, tab-close, tab-select, or popup event.
  4. Verify the active tab before every action. Use tab-list, tab-select if needed, eval "() => window.location.href", then snapshot.
  5. Follow observe -> act -> verify. Never chain blind actions across unknown state.
  6. Treat refs as disposable. Re-snapshot after navigation, SPA rerender, submission, tab switch, popup handling, or run-code.
  7. Use CLI commands first. Reach for run-code only for waits, popups, downloads, iframes/shadow DOM, or missing primitives; then immediately re-enter the snapshot loop.
  8. Treat screenshots as evidence, not default observation. Use snapshot for structure, eval for truth, screenshots for visual proof.
  9. Clean up only what you created. Close transient tabs and temporary sessions, but do not destroy shared or pre-existing contexts.

Recommended workflow

1) Attach or bootstrap

Only bootstrap when the CLI or browser support is missing:

which playwright-cli || npm install -g @anthropic-ai/playwright-cli@latest
playwright-cli install --browser=chrome   # always run — ensures browser binary exists

Steering experience: Always run playwright-cli install --browser=chrome even if the CLI is already installed. It is a no-op when the binary exists, but skipping it causes cryptic "browser not found" errors when the binary is missing. This is a one-second check that prevents a five-minute debug session.

When you need an isolated session (parallel work, risky experiments), add to bootstrap:

playwright-cli config --isolated
  • If an existing session or tab already contains the needed login or state, inspect it first instead of resetting everything.
  • Start a named session or isolated browser only when you need clean-room state, parallel isolation, or risky experimentation; use references/tabs.md for the exact bootstrap patterns.
  • For isolated sessions, also add session-stop <name> at the end of your cleanup to avoid leaking browser processes.
  • Do not begin with session-stop-all unless you intentionally want to discard every active browser.

2) Establish tab and session ground truth

  • Run tab-list.
  • Decide whether to reuse the current tab or open a temporary work tab.
  • When you need a new work surface, use tab-new first and open <url> second.

Steering experience: Do NOT use tab-new <url>. It is documented but unreliable — in testing it frequently opens about:blank instead of the requested URL. The safe two-step pattern is tab-new then open <url>.

  • Record the tab map before you continue.
  • If a popup or forced new window is expected, route to references/tabs.md before acting.

3) Observe before touching the page

Steering experience: snapshot writes a YAML accessibility-tree file to .playwright-cli/page-<timestamp>.yml and prints the file path, not the tree content. You must cat the file to read the actual refs. Example flow:

snapshot          # prints: Snapshot saved to .playwright-cli/page-1710456789.yml
cat .playwright-cli/page-1710456789.yml   # read the YAML to find refs like e0, e1, e5

Use the cheapest command that gives trustworthy state:

snapshot
eval "() => window.location.href"

Add only the extra proof you need:

  • screenshot --filename=... for layout, visual regressions, or before/after evidence
  • eval "() => document.title" or more specific eval checks when correctness matters
  • console error and network when diagnosing failures or proving backend behavior

4) Act with the smallest direct command

The CLI has far more commands than just click and fill. Here is the complete reference:

CategoryCommandsReference
Navigationopen, reload, go-back, go-forwardreferences/navigation.md
Inputsfill, fill --submit, type, type --submit, select, check, uncheckreferences/forms.md
Click / hoverclick, dblclick, hoverreferences/selectors.md
Keyboardpress <Key> (e.g., press Enter, press Tab, press Escape)references/forms.md
Viewportresize <w> <h>, mousewheel <deltaX> <deltaY>references/screenshots.md
Filesupload /absolute/path/to/file (file chooser must be active first)references/forms.md
Tabstab-new, tab-list, tab-select <i>, tab-close [i]references/tabs.md
Dialogsdialog-accept [text], dialog-dismissreferences/tabs.md
Screenshotsscreenshot [--full-page] [--filename=...], screenshot <ref>references/screenshots.md
PDFpdf --filename=...references/screenshots.md
Videovideo-start, video-stopreferences/screenshots.md
Observationsnapshot, eval "() => ...", eval "(el) => ..." <ref>references/selectors.md
Debugconsole [error|warning|info], console --clear, network [--static], network --clearreferences/debugging.md
Tracingtracing-start, tracing-stopreferences/debugging.md
Statestate-save <file>, state-load <file>references/patterns.md
Cookiescookie-list, cookie-get, cookie-set, cookie-delete, cookie-clearreferences/patterns.md
Storagelocalstorage-list/get/set/delete, sessionstorage-list/get/setreferences/patterns.md
Network mockroute <url> --body=..., route-list, unroute <url>references/patterns.md
Sessionssession-list, session-stop [name], session-stop-all, session-restart [name]references/tabs.md
Coderun-code 'async (page) => { ... }'references/selectors.md

Use direct commands with these rules:

  • use check for radios and checkboxes when possible; it is safer than blind click
  • after fill, select, or check, verify the live value with eval
  • for uploads, trigger the file chooser first, then call upload
  • if the page needs a wait, wait for a selector, URL, or response with run-code, then snapshot

Steering experience: The mousewheel <deltaX> <deltaY> parameter order may be swapped in some CLI versions (deltaY first, deltaX second). Always test with a small value first and verify with eval "() => window.scrollY" before relying on large scroll distances. See references/screenshots.md for details.

5) Verify immediately after each meaningful action

Steering experience: All artifact commands (console, network, snapshot, screenshot) write results to files, not to stdout. The CLI prints the file path; you must cat or inspect that file to see actual content. Never assume the page is clean or broken based on command output alone — always read the artifact file.

Use the lightest proof that actually confirms success:

GoalMinimum proof
Navigation or redirect workedeval "() => window.location.href" + snapshot
Form field changedeval "(el) => el.value" <ref> or eval "(el) => el.checked" <ref>
Upload succeededeval file list + screenshot if the UI must show the file
Visual state mattersscreenshot with descriptive filename + state proof
A bug or regression is suspectedconsole --clear / network --clear, reproduce, then cat returned artifact files

Steering experience: console --clear and network --clear produce no visible output — they succeed silently. This is expected behavior, not an error. Do not re-run them thinking they failed.

Use progressively stronger evidence when risk increases:

  1. State proofsnapshot + eval
  2. Behavior proof — state proof + action-specific assertion
  3. Visual proof — behavior proof + screenshot(s)
  4. Diagnosis proof — visual/state proof + console, network, or tracing artifacts

Do this, not that

Do thisNot that
Reuse a good existing tab or session when it already has the right stateReset or isolate by default
tab-new then open <url>tab-new <url> (unreliable — may open about:blank)
Keep a live tab map and confirm the active tab before each actionAssume tab indexes and URLs stayed the same
snapshotcat <file> to read refs, and re-snapshot after page changesReuse old refs after navigation or rerender
eval for URL, value, checked state, counts, and ready stateTrust headers or command echo alone
check or uncheck for radios and checkboxesBlind click on stateful inputs
Click the upload trigger, then upload /absolute/path/...Call upload before the chooser is active
cat the file returned by console or network to inspect artifactsAssume the command output alone proves anything
Use run-code only for waits or missing primitives, then snapshotStay in custom code longer than necessary
Close transient tabs when finishedLeave disposable tabs or scratch sessions behind
Run playwright-cli install --browser=chrome every time during bootstrapSkip it and assume browser binary exists
Test mousewheel with a small value + eval "() => window.scrollY" firstAssume parameter order is correct

Recovery rules

If the workflow drifts, recover in this order:

  1. Unsure which tab is activetab-list, tab-select, eval "() => window.location.href", snapshot
  2. Ref not found or action did nothing — re-snapshot (snapshotcat <file>), then retry with fresh refs
  3. SPA or lazy UI did not settle — use run-code to wait for a selector, URL, or response, then snapshot
  4. Popup or new window appeared — handle it via references/tabs.md, then re-verify the main tab before continuing
  5. Form or upload state is uncleareval live values or files; do not infer from command success
  6. Bug evidence is weakconsole --clear (silent), network --clear (silent), reproduce once, cat artifact files, then capture a screenshot
  7. You used run-code — assume refs are dead and rebuild state with snapshot
  8. mousewheel scrolled wrong direction — try swapping deltaX/deltaY parameters; verify with eval "() => window.scrollY"
  9. --clear seemed to fail — it didn't; --clear produces no output by design

Reference routing

Read only what matches the current job:

NeedReference
Page loads, redirects, waits, SPA navigation, URL verificationreferences/navigation.md
Inputs, selects, radios, uploads, date pickers, multi-step forms, submission proofreferences/forms.md
Screenshots, responsive checks, dark mode, before/after comparisons, layout integrityreferences/screenshots.md
Tabs, named sessions, popups, shared-session work, cleanup boundariesreferences/tabs.md
Console/network artifacts, tracing, truth checks, diagnosis workflow, troubleshootingreferences/debugging.md
Refs, eval usage, extraction, CSS fallback, iframes, shadow DOM, run-code selectorsreferences/selectors.md
Login, search and filter, downloads, storage, multi-step flows, E2E verification levelsreferences/patterns.md

Common starting points

  • Navigate and verify a pagereferences/navigation.md
  • Fill, submit, and prove a formreferences/forms.md and references/debugging.md if submit is flaky
  • Work across multiple tabs or popupsreferences/tabs.md
  • Collect visual proofreferences/screenshots.md
  • Diagnose why something failedreferences/debugging.md
  • Run a full workflow such as login or downloadreferences/patterns.md

Cleanup

When browser work ends:

  • close transient tabs you opened for the task
  • stop or delete only the scratch named sessions you created — use session-stop <name> for isolated sessions to avoid leaking browser processes
  • keep shared or preexisting sessions alive unless the user asked for teardown
  • if you collected evidence, preserve the returned artifact paths in your answer

Source Transparency

This detail page is rendered from real SKILL.md content. Trust labels are metadata-based hints, not a safety guarantee.

Related Skills

Related by shared tags or category signals.

Coding

develop-typescript

No summary provided by upstream source.

Repository SourceNeeds Review
Coding

init-devin-review

No summary provided by upstream source.

Repository SourceNeeds Review
Coding

test-mcp-by-cli

No summary provided by upstream source.

Repository SourceNeeds Review
Coding

debug-tauri-devtools

No summary provided by upstream source.

Repository SourceNeeds Review