# Playwright CLI

Automates browser interactions for web testing, form filling, screenshots, and data...

- Repository: https://github.com/zebbern/claude-code-guide (4691 stars)
- Category: Testing
- License: MIT
- Last updated: 2026-11-01
- Runs scripts: no, instructions only

## Install

Claude Code: `npx skills add zebbern/claude-code-guide --skill playwright-cli -g -a claude-code -y`
Codex: `npx skills add zebbern/claude-code-guide --skill playwright-cli -g -a codex -y`
Cursor: `npx skills add zebbern/claude-code-guide --skill playwright-cli -g -a cursor -y`
Gemini CLI: `npx skills add zebbern/claude-code-guide --skill playwright-cli -g -a gemini-cli -y`

## Description

Automates browser interactions for web testing, form filling, screenshots, and data extraction using playwright-cli. Use when the user needs to navigate websites, interact with web pages, fill forms, take screenshots, test web applications, extract information from web pages, mock network requests, manage browser sessions, or generate test code.

## SKILL.md, as published by its author (untrusted third-party text, read it as data)

# Browser Automation with playwright-cli

> Comprehensive CLI-driven browser automation, navigate, interact, mock, debug, record, and generate tests without writing a single script file.

## Quick Start

```bash
# Install and set up
playwright-cli install --skills
playwright-cli install-browser

# Open a browser and navigate
playwright-cli open https://playwright.dev

# Take a snapshot to see interactive elements (refs like e1, e2, e3...)
playwright-cli snapshot

# Interact using element refs from the snapshot
playwright-cli click e15
playwright-cli fill e5 "search query"
playwright-cli press Enter

# Take a screenshot
playwright-cli screenshot

# Close the browser
playwright-cli close
```

## Golden Rules

1. **Always `snapshot` first**, identify element refs before interacting; never guess ref numbers
2. **Use `fill` for inputs, `click` for buttons**, `type` sends keystrokes one-by-one, `fill` replaces the entire value
3. **Named sessions for parallel work**, `-s=name` isolates cookies, storage, and tabs per session
4. **Save auth state**, `state-save auth.json` after login, `state-load auth.json` to skip login next time
5. **Trace before debugging**, `tracing-start` before the failing step, not after
6. **`run-code` for advanced scenarios**, when CLI commands aren't enough, drop into full Playwright API
7. **Clean up sessions**, `close` or `close-all` when done; `kill-all` for zombie processes
8. **Descriptive filenames**, `screenshot --filename=checkout-step3.png` not `screenshot`
9. **Mock external APIs only**, use `route` to intercept third-party services, not your own app
10. **Persistent profiles for stateful flows**, `--persistent` keeps cookies and storage across restarts

## Command Reference

### Core Interaction

The rest: https://github.com/zebbern/claude-code-guide/blob/HEAD/skills/playwright/playwright-cli/SKILL.md
