| name | playwright-cli |
| description | Automates browser interactions for web testing, form filling, screenshots, and data extraction. Use when the user needs to navigate websites, interact with web pages, fill forms, take screenshots, test web applications, or extract information from web pages. |
| allowed-tools | Bash(playwright-cli:*) |
Browser Automation with playwright-cli
Quick start
mise run browser -- https://example.is
mise run browser-no-proxy -- https://example.is
playwright-cli -s=proxy snapshot
playwright-cli -s=proxy screenshot --filename=tmp/with-proxy.png
playwright-cli -s=no-proxy snapshot
playwright-cli -s=no-proxy screenshot --filename=tmp/without-proxy.png
Proxy testing workflow
Prerequisites
The proxy must be running with a blocklist:
mise run dev -- --blocklist examples/is.rules
1. Open browser sessions
mise run browser -- https://example.is
mise run browser-no-proxy -- https://example.is
2. Find rules for the target domain
grep "example.is##" examples/is.rules
grep "||.*example" examples/is.rules
grep "^##" examples/is.rules
3. Verify element hiding CSS injection
Element hiding injects display: none !important CSS rules into HTML responses. Check for injected <style> tags:
playwright-cli -s=proxy eval "() => {
const injected = [...document.querySelectorAll('style')].filter(s =>
s.textContent.includes('display: none !important')
);
return {
found: injected.length > 0,
css: injected.map(s => s.textContent).join('')
};
}"
4. Verify request blocking
Check network log for failed requests to blocked domains:
playwright-cli -s=proxy network
Requests to blocked domains should appear as failed. Compare with the no-proxy session:
playwright-cli -s=no-proxy network
5. Take comparison screenshots
playwright-cli -s=proxy screenshot --filename=tmp/with-proxy.png
playwright-cli -s=no-proxy screenshot --filename=tmp/without-proxy.png
6. Cleanup
playwright-cli -s=proxy close
playwright-cli -s=no-proxy close
Commands
Core
playwright-cli open [url]
playwright-cli goto <url>
playwright-cli close
playwright-cli type <text>
playwright-cli click <ref>
playwright-cli fill <ref> <text>
playwright-cli hover <ref>
playwright-cli select <ref> <val>
playwright-cli check <ref>
playwright-cli uncheck <ref>
playwright-cli snapshot
playwright-cli eval <func> [ref]
playwright-cli resize <w> <h>
Navigation
playwright-cli go-back
playwright-cli go-forward
playwright-cli reload
Keyboard and 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 as
playwright-cli screenshot
playwright-cli screenshot <ref>
playwright-cli screenshot --filename=f
playwright-cli pdf --filename=page.pdf
Tabs
playwright-cli tab-list
playwright-cli tab-new [url]
playwright-cli tab-close [index]
playwright-cli tab-select <index>
Network
playwright-cli route <pattern>
playwright-cli route-list
playwright-cli unroute [pattern]
playwright-cli network
DevTools
playwright-cli console [min-level]
playwright-cli run-code <code>
playwright-cli tracing-start
playwright-cli tracing-stop
Sessions
playwright-cli -s=name <cmd>
playwright-cli list
playwright-cli close-all
playwright-cli kill-all
Open parameters
playwright-cli open --browser=chrome
playwright-cli open --config=file.json
playwright-cli open --persistent
playwright-cli open --profile=<path>
Snapshots
After each command, playwright-cli provides a snapshot of the current browser state with element refs (e.g. e3, e15) that can be used with click, fill, and other commands.
> playwright-cli -s=proxy goto https://example.is
- Page URL: https://example.is/
- Page Title: Example
[Snapshot](.playwright-cli/page-2026-02-26T10-00-00-000Z.yml)
Troubleshooting
- "proxy is not running" -- start the proxy first with
mise run dev -- --blocklist examples/is.rules
- HTTPS timeouts -- the proxy config (
playwright-cli-proxy.json) sets ignoreHTTPSErrors: true. Verify the config file exists and is passed via --config.
- Navigation timeout -- the target site may be down. Try
curl --max-time 5 https://example.is to verify.
- Cloudflare challenge -- some sites block headless browsers. The page title will be "Just a moment...". Try a different site.
- No element hiding CSS -- the page may use zstd compression (not yet supported) or the selectors may no longer match the current site markup.
- Stale sessions -- if browsers become unresponsive, run
playwright-cli kill-all.