| name | agent-browser |
| 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(npx agent-browser:*) |
Browser Automation with npx agent-browser
Quick start
npx agent-browser open <url>
npx agent-browser snapshot -i
npx agent-browser click @e1
npx agent-browser fill @e2 "text"
npx agent-browser close
Core workflow
- Navigate:
npx agent-browser open <url>
- Snapshot:
npx agent-browser snapshot -i (returns elements with refs like @e1, @e2)
- Interact using refs from the snapshot
- Re-snapshot after navigation or significant DOM changes
Commands
Navigation
npx agent-browser open <url>
npx agent-browser back
npx agent-browser forward
npx agent-browser reload
npx agent-browser close
npx agent-browser connect 9222
Snapshot (page analysis)
npx agent-browser snapshot
npx agent-browser snapshot -i
npx agent-browser snapshot -c
npx agent-browser snapshot -d 3
npx agent-browser snapshot -s "#main"
Interactions (use @refs from snapshot)
npx agent-browser click @e1
npx agent-browser dblclick @e1
npx agent-browser focus @e1
npx agent-browser fill @e2 "text"
npx agent-browser type @e2 "text"
npx agent-browser press Enter
npx agent-browser press Control+a
npx agent-browser keydown Shift
npx agent-browser keyup Shift
npx agent-browser hover @e1
npx agent-browser check @e1
npx agent-browser uncheck @e1
npx agent-browser select @e1 "value"
npx agent-browser select @e1 "a" "b"
npx agent-browser scroll down 500
npx agent-browser scrollintoview @e1
npx agent-browser drag @e1 @e2
npx agent-browser upload @e1 file.pdf
Get information
npx agent-browser get text @e1
npx agent-browser get html @e1
npx agent-browser get value @e1
npx agent-browser get attr @e1 href
npx agent-browser get title
npx agent-browser get url
npx agent-browser get count ".item"
npx agent-browser get box @e1
npx agent-browser get styles @e1
Check state
npx agent-browser is visible @e1
npx agent-browser is enabled @e1
npx agent-browser is checked @e1
Screenshots & PDF
npx agent-browser screenshot
npx agent-browser screenshot path.png
npx agent-browser screenshot --full
npx agent-browser pdf output.pdf
Video recording
npx agent-browser record start ./demo.webm
npx agent-browser click @e1
npx agent-browser record stop
npx agent-browser record restart ./take2.webm
Recording creates a fresh context but preserves cookies/storage from your session. If no URL is provided, it
automatically returns to your current page. For smooth demos, explore first, then start recording.
Wait
npx agent-browser wait @e1
npx agent-browser wait 2000
npx agent-browser wait --text "Success"
npx agent-browser wait --url "**/dashboard"
npx agent-browser wait --load networkidle
npx agent-browser wait --fn "window.ready"
Mouse control
npx agent-browser mouse move 100 200
npx agent-browser mouse down left
npx agent-browser mouse up left
npx agent-browser mouse wheel 100
Semantic locators (alternative to refs)
npx agent-browser find role button click --name "Submit"
npx agent-browser find text "Sign In" click
npx agent-browser find text "Sign In" click --exact
npx agent-browser find label "Email" fill "user@test.com"
npx agent-browser find placeholder "Search" type "query"
npx agent-browser find alt "Logo" click
npx agent-browser find title "Close" click
npx agent-browser find testid "submit-btn" click
npx agent-browser find first ".item" click
npx agent-browser find last ".item" click
npx agent-browser find nth 2 "a" hover
Browser settings
npx agent-browser set viewport 1920 1080
npx agent-browser set device "iPhone 14"
npx agent-browser set geo 37.7749 -122.4194
npx agent-browser set offline on
npx agent-browser set headers '{"X-Key":"v"}'
npx agent-browser set credentials user pass
npx agent-browser set media dark
npx agent-browser set media light reduced-motion
Cookies & Storage
npx agent-browser cookies
npx agent-browser cookies set name value
npx agent-browser cookies clear
npx agent-browser storage local
npx agent-browser storage local key
npx agent-browser storage local set k v
npx agent-browser storage local clear
Network
npx agent-browser network route <url>
npx agent-browser network route <url> --abort
npx agent-browser network route <url> --body '{}'
npx agent-browser network unroute [url]
npx agent-browser network requests
npx agent-browser network requests --filter api
Tabs & Windows
npx agent-browser tab
npx agent-browser tab new [url]
npx agent-browser tab 2
npx agent-browser tab close
npx agent-browser tab close 2
npx agent-browser window new
Frames
npx agent-browser frame "#iframe"
npx agent-browser frame main
Dialogs
npx agent-browser dialog accept [text]
npx agent-browser dialog dismiss
JavaScript
npx agent-browser eval "document.title"
Global options
npx agent-browser --session <name> ...
npx agent-browser --json ...
npx agent-browser --headed ...
npx agent-browser --full ...
npx agent-browser --cdp <port> ...
npx agent-browser -p <provider> ...
npx agent-browser --proxy <url> ...
npx agent-browser --headers <json> ...
npx agent-browser --executable-path <p>
npx agent-browser --extension <path> ...
npx agent-browser --help
npx agent-browser --version
npx agent-browser <command> --help
Proxy support
npx agent-browser --proxy http://proxy.com:8080 open example.com
npx agent-browser --proxy http://user:pass@proxy.com:8080 open example.com
npx agent-browser --proxy socks5://proxy.com:1080 open example.com
Environment variables
AGENT_BROWSER_SESSION="mysession"
AGENT_BROWSER_EXECUTABLE_PATH="/path/chrome"
AGENT_BROWSER_EXTENSIONS="/ext1,/ext2"
AGENT_BROWSER_PROVIDER="your-cloud-browser-provider"
AGENT_BROWSER_STREAM_PORT="9223"
AGENT_BROWSER_HOME="/path/to/npx agent-browser"
Example: Form submission
npx agent-browser open https://example.com/form
npx agent-browser snapshot -i
npx agent-browser fill @e1 "user@example.com"
npx agent-browser fill @e2 "password123"
npx agent-browser click @e3
npx agent-browser wait --load networkidle
npx agent-browser snapshot -i
Example: Authentication with saved state
npx agent-browser open https://app.example.com/login
npx agent-browser snapshot -i
npx agent-browser fill @e1 "username"
npx agent-browser fill @e2 "password"
npx agent-browser click @e3
npx agent-browser wait --url "**/dashboard"
npx agent-browser state save auth.json
npx agent-browser state load auth.json
npx agent-browser open https://app.example.com/dashboard
Sessions (parallel browsers)
npx agent-browser --session test1 open site-a.com
npx agent-browser --session test2 open site-b.com
npx agent-browser session list
JSON output (for parsing)
Add --json for machine-readable output:
npx agent-browser snapshot -i --json
npx agent-browser get text @e1 --json
Debugging
npx agent-browser --headed open example.com
npx agent-browser --cdp 9222 snapshot
npx agent-browser connect 9222
npx agent-browser console
npx agent-browser console --clear
npx agent-browser errors
npx agent-browser errors --clear
npx agent-browser highlight @e1
npx agent-browser trace start
npx agent-browser trace stop trace.zip
npx agent-browser record start ./debug.webm
npx agent-browser record stop
Deep-dive documentation
For detailed patterns and best practices, see:
Ready-to-use templates
Executable workflow scripts for common patterns:
Usage:
./templates/form-automation.sh https://example.com/form
./templates/authenticated-session.sh https://app.example.com/login
./templates/capture-workflow.sh https://example.com ./output
HTTPS Certificate Errors
For sites with self-signed or invalid certificates:
npx agent-browser open https://localhost:8443 --ignore-https-errors