Loading...
Loading...
Playwright-based browser automation via Chrome extension + MCP/CLI. Connects to your RUNNING browser (existing logins, cookies, extensions preserved). Use for authenticated flows, stateful web automation, and AI agent browser control without re-logging in.
npx skill4agent add supercent-io/skills-template playwriterjfeammnjpkecdekppnclgkkffahnhfhenpm install -g playwriter
# or run without installing:
npx playwriter@latest --helplocalhost:19988# 1. Create a session
playwriter session new
# 2. Navigate and observe
playwriter -s 1 -e 'await page.goto("https://example.com")'
playwriter -s 1 -e 'await snapshot({ page })'
# 3. Interact based on snapshot output
playwriter -s 1 -e 'await page.locator("aria-ref=e5").click()'
# 4. Re-observe after action
playwriter -s 1 -e 'await snapshot({ page })'# Create a new isolated stateful session
playwriter session new
# List all active sessions (shows browser, profile, state info)
playwriter session list
# Delete a session and clear its state
playwriter session delete <sessionId>
# Reset the CDP connection and clear execution environment
playwriter session reset <sessionId># Navigate to a URL
playwriter -s 1 -e 'await page.goto("https://github.com")'
# Fill a form field
playwriter -s 1 -e 'await page.fill("#search", "playwriter"); await page.keyboard.press("Enter")'
# Get accessibility snapshot (preferred over screenshots for text content)
playwriter -s 1 -e 'await snapshot({ page })'
# Take screenshot with visual accessibility labels (color-coded by element type)
playwriter -s 1 -e 'await screenshotWithAccessibilityLabels({ page })'
# Store state between calls (state object persists within session)
playwriter -s 1 -e 'state.url = page.url(); state.title = await page.title()'
playwriter -s 1 -e 'console.log(state.url, state.title)'playwriter -s 1 -e "$(cat <<'EOF'
const text = await page.textContent('h1');
state.heading = text;
await snapshot({ page });
EOF
)"~/.claude/settings.json{
"mcpServers": {
"playwriter": {
"command": "npx",
"args": ["-y", "playwriter@latest"]
}
}
}{
"mcpServers": {
"playwriter": {
"command": "npx",
"args": ["-y", "playwriter@latest"],
"env": {
"PLAYWRITER_HOST": "your-relay-host",
"PLAYWRITER_TOKEN": "your-secret-token",
"PLAYWRITER_SESSION": "1"
}
}
}
}| Tool | Description |
|---|---|
| Run arbitrary JavaScript Playwright code ( |
| Recreate CDP connection, clear state — use after connection failures |
| Global | Description |
|---|---|
| Current Playwright page |
| Browser context |
| Persistent object — survives multiple |
| Accessibility tree as text (token-efficient) |
| Screenshot with color-coded element markers |
| Article text via Mozilla Readability |
| Smart load detection |
| Browser console errors/logs |
| Cleaned DOM HTML |
| Get selector for a DOM element |
| React component source tree |
screenshotWithAccessibilityLabels({ page })| Color | Element type |
|---|---|
| Yellow | Links |
| Orange | Buttons |
| Coral | Inputs |
| Pink | Checkboxes |
| Peach | Sliders |
aria-refplaywriter -s 1 -e 'await page.locator("aria-ref=e5").click()'# Intercept network requests
playwriter -s 1 -e 'state.requests = []; page.on("request", r => state.requests.push(r.url()))'
# Check collected requests later
playwriter -s 1 -e 'console.log(state.requests.slice(-5).join("\n"))'
# Screen recording
playwriter -s 1 -e 'await recording.start()'
# ... do actions ...
playwriter -s 1 -e 'const video = await recording.stop(); state.video = video'# On the machine with Chrome:
playwriter serve --token my-secret --replace
# From agent machine:
playwriter --host <ip-or-hostname> --token my-secret -s 1 -e 'await page.goto("https://example.com")'snapshot({ page })snapshot()aria-refdata-testidstateresetplaywriter session reset| Issue | Solution |
|---|---|
| Extension not connecting | Click extension icon on the tab; icon must be green |
| Extension auto-starts server; check Chrome is running with extension installed |
| Code execution timeout | Increase with |
| Click fails silently | Use |
| Stale session | Run |
| Remote access failing | Confirm |
playwriter skillplaywriter logfile