| name | playwright-cli |
| description | Browser automation via Playwright CLI. Open pages, interact with elements, take screenshots, and more. Ideal for coding agents and automated testing workflows. |
| metadata | {"clawdbot":{"emoji":"🎭","requires":{"bins":["playwright-cli"]},"install":[{"id":"node","kind":"node","package":"@playwright/mcp","bins":["playwright-cli"],"label":"Install Playwright CLI (npm)"}]}} |
Playwright CLI
Browser automation via Playwright. Token-efficient CLI for coding agents.
Installation
npm install -g @playwright/mcp@latest
playwright-cli --help
Core Commands
| Command | Description |
|---|
playwright-cli open <url> | Open URL in browser |
playwright-cli close | Close the page |
playwright-cli type <text> | Type text into editable element |
playwright-cli click <ref> [button] | Click on element |
playwright-cli dblclick <ref> [button] | Double click |
playwright-cli fill <ref> <text> | Fill text into field |
playwright-cli drag <startRef> <endRef> | Drag and drop |
playwright-cli hover <ref> | Hover over element |
playwright-cli check <ref> | Check checkbox/radio |
playwright-cli uncheck <ref> | Uncheck checkbox |
playwright-cli select <ref> <val> | Select dropdown option |
playwright-cli snapshot | Capture page snapshot for refs |
Navigation
playwright-cli go-back
playwright-cli go-forward
playwright-cli reload
Keyboard & Mouse
playwright-cli press <key>
playwright-cli keydown <key>
playwright-cli keyup <key>
playwright-cli mousemove <x> <y>
playwright-cli mousedown [button]
playwright-cli mouseup [button]
playwright-cli mousewheel <dx> <dy>
Save & Export
playwright-cli screenshot [ref]
playwright-cli pdf
Tabs
playwright-cli tab-list
playwright-cli tab-new [url]
playwright-cli tab-close [index]
playwright-cli tab-select <index>
DevTools
playwright-cli console [min-level]
playwright-cli network
playwright-cli run-code <code>
playwright-cli tracing-start
playwright-cli tracing-stop
Sessions
playwright-cli session-list
playwright-cli session-stop [name]
playwright-cli session-stop-all
playwright-cli session-delete [name]
Headed Mode
playwright-cli open https://example.com --headed
Examples
playwright-cli open https://example.com
playwright-cli type "search query"
playwright-cli press Enter
playwright-cli screenshot
playwright-cli open https://site1.com
playwright-cli --session=project-a open https://site2.com
Environment Variables
| Variable | Description |
|---|
PLAYWRIGHT_MCP_BROWSER | Browser: chrome, firefox, webkit, msedge |
PLAYWRIGHT_MCP_HEADLESS | Run headless (default: headed) |
PLAYWRIGHT_MCP_ALLOWED_HOSTS | Comma-separated allowed hosts |
PLAYWRIGHT_MCP_CONFIG | Path to config file |
Configuration
Create playwright-cli.json for persistent settings:
{
"browser": {
"browserName": "chromium",
"headless": false
},
"outputDir": "./playwright-output",
"console": {
"level": "info"
}
}
Notes
- Cross-platform — requires Node.js 18+ (Linux, macOS, Windows)
- Sessions persist cookies/storage by default
- Use
--session flag for isolated browser instances
- Snapshots return element refs for subsequent commands
Source
https://github.com/microsoft/playwright-cli