Playwright Browser Automation
Use this skill as the default path for browser automation in this environment.
Quick Start
Bootstrap the local runtime once:
python scripts/pwcli.py install-runtime
Reuse an existing named session or open a new one:
python scripts/pwcli.py ensure-open https://www.webofscience.com --session wos --browser chrome --headed
Run normal Playwright CLI commands through the wrapper so they use the local runtime instead of npx each time:
python scripts/pwcli.py snapshot -s wos
python scripts/pwcli.py click e12 -s wos
python scripts/pwcli.py fill e5 "search terms" -s wos
python scripts/pwcli.py screenshot -s wos
On Windows, use the shorter PowerShell wrapper if convenient:
& .\scripts\pw.ps1 ensure-open https://www.webofscience.com --session wos --browser chrome --headed
Default Workflow
- Run
install-runtime the first time on a machine or after deleting the cached runtime.
- Start with
ensure-open so the browser session is reused when possible instead of reopened.
- Keep using the same named session for
snapshot, click, fill, press, tab-list, screenshot, and download-related commands.
- When a site requires manual sign-in, institution authentication, CAPTCHA, or MFA, stop at the login page and let the user take over in the opened browser.
- After the user confirms login is complete, resume automation against the same session.
Session Rules
- Prefer a short, task-specific session name such as
wos, publisher-download, or form-review.
- Keep the same session through the whole task unless isolation is necessary.
- Use
ensure-open instead of raw open whenever session reuse is desirable.
- Use
--browser chrome --headed for tasks that depend on user-visible login or downloads.
- Run the wrapper from the task workspace so
.playwright-cli/ artifacts stay with the current project instead of inside the skill directory.
Runtime Notes
- The wrapper installs
@playwright/cli under assets/pwcli-runtime/ once and reuses that local installation later.
- The wrapper still forwards normal Playwright CLI commands, so existing
snapshot, click, fill, press, tab-list, and screenshot habits keep working.
- Sessions opened before switching to this skill may not appear in the wrapper's session list. Reopen those tasks once with
ensure-open, then keep using the wrapper for the rest of the task.
- If the runtime becomes stale or corrupted, rerun
install-runtime --force.
- Do not commit downloaded runtime caches, cookies, or storage state to Git.
References
Read references/workflows.md for session patterns, login handoff guidance, and example command sequences.
1---2name: playwright-browser-automation3description: Default browser automation workflow for this machine using Playwright CLI and the local wrapper scripts in this skill. Use when a task involves opening websites, navigating pages, clicking UI elements, filling forms, taking screenshots, collecting page data, handing login back to the user, or downloading files, and prefer Playwright over browser MCP flows or ad hoc browser commands.4---56# Playwright Browser Automation78Use this skill as the default path for browser automation in this environment.910## Quick Start1112Bootstrap the local runtime once:1314```powershell15python scripts/pwcli.py install-runtime16```1718Reuse an existing named session or open a new one:1920```powershell21python scripts/pwcli.py ensure-open https://www.webofscience.com --session wos --browser chrome --headed22```2324Run normal Playwright CLI commands through the wrapper so they use the local runtime instead of `npx` each time:2526```powershell27python scripts/pwcli.py snapshot -s wos28python scripts/pwcli.py click e12 -s wos29python scripts/pwcli.py fill e5 "search terms" -s wos30python scripts/pwcli.py screenshot -s wos31```3233On Windows, use the shorter PowerShell wrapper if convenient:3435```powershell36& .\scripts\pw.ps1 ensure-open https://www.webofscience.com --session wos --browser chrome --headed37```3839## Default Workflow40411. Run `install-runtime` the first time on a machine or after deleting the cached runtime.422. Start with `ensure-open` so the browser session is reused when possible instead of reopened.433. Keep using the same named session for `snapshot`, `click`, `fill`, `press`, `tab-list`, `screenshot`, and download-related commands.444. When a site requires manual sign-in, institution authentication, CAPTCHA, or MFA, stop at the login page and let the user take over in the opened browser.455. After the user confirms login is complete, resume automation against the same session.4647## Session Rules4849- Prefer a short, task-specific session name such as `wos`, `publisher-download`, or `form-review`.50- Keep the same session through the whole task unless isolation is necessary.51- Use `ensure-open` instead of raw `open` whenever session reuse is desirable.52- Use `--browser chrome --headed` for tasks that depend on user-visible login or downloads.53- Run the wrapper from the task workspace so `.playwright-cli/` artifacts stay with the current project instead of inside the skill directory.5455## Runtime Notes5657- The wrapper installs `@playwright/cli` under `assets/pwcli-runtime/` once and reuses that local installation later.58- The wrapper still forwards normal Playwright CLI commands, so existing `snapshot`, `click`, `fill`, `press`, `tab-list`, and `screenshot` habits keep working.59- Sessions opened before switching to this skill may not appear in the wrapper's session list. Reopen those tasks once with `ensure-open`, then keep using the wrapper for the rest of the task.60- If the runtime becomes stale or corrupted, rerun `install-runtime --force`.61- Do not commit downloaded runtime caches, cookies, or storage state to Git.6263## References6465Read [references/workflows.md](references/workflows.md) for session patterns, login handoff guidance, and example command sequences.