# Playwright Browser Automation

> 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.

- Skill: `whisperas/playwright-browser-automation` (Agent Skill, multi-file: 6 files)
- Install (CLI): `npx skillmds@latest add whisperas/playwright-browser-automation`
- Raw SKILL.md: https://api.skillmd.com/api/skills/whisperas/playwright-browser-automation/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: AI & ML
- Author: WhisperAS (https://skillmd.com/u/whisperas)
- Updated: 2026-09-22
- Page: https://skillmd.com/skills/whisperas/playwright-browser-automation

---


# Playwright Browser Automation

Use this skill as the default path for browser automation in this environment.

## Quick Start

Bootstrap the local runtime once:

```powershell
python scripts/pwcli.py install-runtime
```

Reuse an existing named session or open a new one:

```powershell
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:

```powershell
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:

```powershell
& .\scripts\pw.ps1 ensure-open https://www.webofscience.com --session wos --browser chrome --headed
```

## Default Workflow

1. Run `install-runtime` the first time on a machine or after deleting the cached runtime.
2. Start with `ensure-open` so the browser session is reused when possible instead of reopened.
3. Keep using the same named session for `snapshot`, `click`, `fill`, `press`, `tab-list`, `screenshot`, and download-related commands.
4. 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.
5. 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](references/workflows.md) for session patterns, login handoff guidance, and example command sequences.

