Skip to content

Usage

Minimal Example: Open a Page, Read It, Click, Fill, Close

bash
# 1. Open a page
agent-browser open https://example.com

# 2. Get the compact accessibility tree (interactive elements only)
agent-browser snapshot -i

Sample output from snapshot -i:

- heading "Example Domain" [ref=e1] [level=1]
- link "More information..." [ref=e2]
bash
# 3. Click an element by its ref
agent-browser click @e2

# 4. Fill a form field by ref
agent-browser fill @e3 "test@example.com"

# 5. Take a screenshot
agent-browser screenshot page.png

# 6. Close the browser
agent-browser close

Key Commands

CommandWhat it does
agent-browser open <url>Navigate to a URL
agent-browser snapshotFull accessibility tree
agent-browser snapshot -iInteractive elements only (compact, token-efficient)
agent-browser click @eNClick element by ref
agent-browser fill @eN "text"Clear and fill an input
agent-browser screenshot <file>Capture page as PNG
agent-browser closeEnd the browser session

Session Persistence

Save and restore auth state (cookies, localStorage) across runs:

bash
# Save session state after login
agent-browser save-session ./session.json

# Restore session on next run
agent-browser open https://app.example.com --session ./session.json

Add session.json to .gitignore -- it contains plaintext tokens.

Proxy Support

bash
agent-browser open https://example.com --proxy socks5://user:pass@proxy.host:1080

Domain Restriction

bash
agent-browser open https://example.com --allowed-domains example.com,api.example.com

JSON Output (for agent pipelines)

bash
agent-browser snapshot -i --json

Returns structured JSON with refs, roles, names, and bounds -- suitable for piping directly into an LLM prompt.