| name | agent-browser |
| description | Drive a real browser to validate web apps end-to-end. Use when you need to navigate to a URL, interact with UI elements, fill forms, click buttons, take screenshots, assert page state, or run a full end-to-end validation flow for a web feature. The primary tool for automated browser-based E2E testing in the AI Layer. |
agent-browser — Automated E2E Browser Testing
agent-browser is a CLI-driven browser automation tool (by Vercel Labs) that the AI agent controls directly via shell commands. No Playwright/Puppeteer code required — the agent issues commands, reads the structured output, and makes decisions.
Installation
npm install -g agent-browser
agent-browser install
Platform notes:
- macOS/Linux: Works natively after install.
- Windows: Has a known issue with Unix domain sockets. Use WSL as a workaround, or run from a Linux container.
- Docker/CI: Install in the image with the two commands above.
Core workflow
- Navigate:
agent-browser open <url>
- Snapshot:
agent-browser snapshot -i — returns interactive elements tagged with refs (@e1, @e2, …)
- Interact using those refs
- Re-snapshot after navigation or significant DOM changes
- Assert state with
get, is, or wait commands
- Screenshot for evidence:
agent-browser screenshot path.png
E2E Testing Protocol
When using agent-browser to validate a feature end-to-end:
- Start the dev/preview server if it is not already running (check CLAUDE.md for the project's start command).
- Navigate to the feature's entry URL.
- Snapshot to discover the interactive elements.
- Exercise the happy path — fill inputs, click buttons, submit forms, assert success state.
- Exercise key error/edge paths — missing required fields, invalid input, auth-required pages.
- Screenshot at each key moment — before interaction, after success, after error. Save to
screenshots/ with descriptive names.
- Check console errors with
agent-browser errors at the end of the session.
- Close the browser:
agent-browser close.
Commands
Navigation
agent-browser open <url>
agent-browser back
agent-browser forward
agent-browser reload
agent-browser close
Snapshot (page analysis)
agent-browser snapshot
agent-browser snapshot -i
agent-browser snapshot -c
agent-browser snapshot -d 3
agent-browser snapshot -s "#main"
Interactions (use @refs from snapshot)
agent-browser click @e1
agent-browser dblclick @e1
agent-browser focus @e1
agent-browser fill @e2 "text"
agent-browser type @e2 "text"
agent-browser press Enter
agent-browser press Control+a
agent-browser hover @e1
agent-browser check @e1
agent-browser uncheck @e1
agent-browser select @e1 "value"
agent-browser scroll down 500
agent-browser scrollintoview @e1
agent-browser drag @e1 @e2
agent-browser upload @e1 file.pdf
Get information / Assert state
agent-browser get text @e1
agent-browser get html @e1
agent-browser get value @e1
agent-browser get attr @e1 href
agent-browser get title
agent-browser get url
agent-browser get count ".item"
agent-browser get box @e1
agent-browser is visible @e1
agent-browser is enabled @e1
agent-browser is checked @e1
Wait / Synchronization
agent-browser wait @e1
agent-browser wait 2000
agent-browser wait --text "Success"
agent-browser wait --url "**/dashboard"
agent-browser wait --load networkidle
agent-browser wait --fn "window.ready"
Screenshots & PDF
agent-browser screenshot
agent-browser screenshot screenshots/step1.png
agent-browser screenshot --full
agent-browser pdf output.pdf
Semantic locators (alternative to @refs)
agent-browser find role button click --name "Submit"
agent-browser find text "Sign In" click
agent-browser find label "Email" fill "user@test.com"
agent-browser find first ".item" click
agent-browser find nth 2 "a" text
Debugging
agent-browser open <url> --headed
agent-browser console
agent-browser errors
agent-browser highlight @e1
agent-browser trace start
agent-browser trace stop trace.zip
agent-browser record start ./demo.webm
agent-browser record stop
JavaScript
agent-browser eval "document.title"
Network (mocking/interception)
agent-browser network route <url>
agent-browser network route <url> --abort
agent-browser network route <url> --body '{}'
agent-browser network unroute [url]
agent-browser network requests
Sessions (parallel browsers)
agent-browser --session test1 open site-a.com
agent-browser --session test2 open site-b.com
agent-browser session list
Saved auth state
agent-browser open https://app.example.com/login
agent-browser fill @e1 "username"
agent-browser fill @e2 "password"
agent-browser click @e3
agent-browser wait --url "**/dashboard"
agent-browser state save auth.json
agent-browser state load auth.json
agent-browser open https://app.example.com/dashboard
JSON output (for programmatic checks)
agent-browser snapshot -i --json
agent-browser get text @e1 --json
Example: End-to-end form submission test
agent-browser open http://localhost:3000/signup
agent-browser snapshot -i
agent-browser fill @e1 "test@example.com"
agent-browser fill @e2 "SecurePass123!"
agent-browser screenshot screenshots/before-submit.png
agent-browser click @e3
agent-browser wait --url "**/dashboard"
agent-browser screenshot screenshots/after-signup.png
agent-browser get title
agent-browser open http://localhost:3000/signup
agent-browser snapshot -i
agent-browser click @e3
agent-browser wait --text "required"
agent-browser screenshot screenshots/validation-errors.png
agent-browser errors
agent-browser close
Integration with plan-feature validation levels
When a plan's Level 5 (E2E / Browser Automation) is reached:
- Confirm the dev server is running.
- Follow the E2E Testing Protocol above.
- Save screenshots to
screenshots/<ticket-id>-<description>.png.
- Paste the screenshot paths and a pass/fail summary into the plan's completion checklist.
Notes
- Always re-snapshot after a navigation or significant DOM mutation — refs are invalidated.
- Prefer
agent-browser wait --load networkidle after form submissions before asserting state.
- For CI environments, omit
--headed; for local debugging, add it so you can watch the browser.
agent-browser errors at the end of a session catches JS exceptions that wouldn't otherwise surface.