Browser Automation with agent-browser
Core Workflow
Every browser automation follows this pattern:
- Navigate:
agent-browser open <url>
- Snapshot:
agent-browser snapshot -i (get element refs like @e1, @e2)
- Interact: Use refs to click, fill, select
- Re-snapshot: After navigation or DOM changes, get fresh refs
agent-browser open https://example.com/form
agent-browser snapshot -i
# Output: @e1 [input type="email"], @e2 [input type="password"], @e3 [button] "Submit"
agent-browser fill @e1 "user@example.com"
agent-browser fill @e2 "password123"
agent-browser click @e3
agent-browser wait --load networkidle
agent-browser snapshot -i # Check result
Essential Commands
# Navigation
agent-browser open <url> # Navigate
agent-browser close # Close browser
# Snapshot
agent-browser snapshot -i # Interactive elements with refs (recommended)
agent-browser snapshot -i -C # Include cursor-interactive elements
# Interaction (use @refs from snapshot)
agent-browser click @e1 # Click
agent-browser fill @e2 "text" # Clear and type
agent-browser select @e1 "option" # Select dropdown
agent-browser check @e1 # Checkbox
agent-browser press Enter # Key press
# Wait
agent-browser wait @e1 # Wait for element
agent-browser wait --load networkidle # Wait for network idle
# Capture
agent-browser screenshot # Screenshot
agent-browser screenshot --full # Full page
Ref Lifecycle (Important)
Refs (@e1, @e2, etc.) are invalidated when the page changes. Always re-snapshot after clicking links/buttons that navigate, form submissions, or dynamic content loading.
Deep-Dive Documentation
| Reference |
When to Use |
| references/commands.md |
Full command reference with all options |
| references/snapshot-refs.md |
Ref lifecycle, invalidation rules, troubleshooting |
| references/session-management.md |
Parallel sessions, state persistence, concurrent scraping |
| references/authentication.md |
Login flows, OAuth, 2FA handling, state reuse |
| references/video-recording.md |
Recording workflows for debugging and documentation |
| references/proxy-support.md |
Proxy configuration, geo-testing, rotating proxies |
| references/common-patterns.md |
Form submission, auth, data extraction, parallel sessions, iOS simulator |
| references/semantic-locators.md |
Alternatives to refs |
| references/javascript-evaluation.md |
eval rules, --stdin/-b explanation |
Ready-to-Use Templates
| Template |
Description |
| templates/form-automation.sh |
Form filling with validation |
| templates/authenticated-session.sh |
Login once, reuse state |
| templates/capture-workflow.sh |
Content extraction with screenshots |
1---2name: agent-browser3description: Browser automation CLI for AI agents. Use when the user needs to interact with websites, including navigating pages, filling forms, clicking buttons, taking screenshots, extracting data, testing web apps, or automating any browser task. Triggers include requests to "open a website", "fill out a form", "click a button", "take a screenshot", "scrape data from a page", "test this web app", "login to a site", "automate browser actions", or any task requiring programmatic web interaction.4---56# Browser Automation with agent-browser78## Core Workflow910Every browser automation follows this pattern:11121. **Navigate**: `agent-browser open <url>`132. **Snapshot**: `agent-browser snapshot -i` (get element refs like `@e1`, `@e2`)143. **Interact**: Use refs to click, fill, select154. **Re-snapshot**: After navigation or DOM changes, get fresh refs1617```bash18agent-browser open https://example.com/form19agent-browser snapshot -i20# Output: @e1 [input type="email"], @e2 [input type="password"], @e3 [button] "Submit"2122agent-browser fill @e1 "user@example.com"23agent-browser fill @e2 "password123"24agent-browser click @e325agent-browser wait --load networkidle26agent-browser snapshot -i # Check result27```2829## Essential Commands3031```bash32# Navigation33agent-browser open <url> # Navigate34agent-browser close # Close browser3536# Snapshot37agent-browser snapshot -i # Interactive elements with refs (recommended)38agent-browser snapshot -i -C # Include cursor-interactive elements3940# Interaction (use @refs from snapshot)41agent-browser click @e1 # Click42agent-browser fill @e2 "text" # Clear and type43agent-browser select @e1 "option" # Select dropdown44agent-browser check @e1 # Checkbox45agent-browser press Enter # Key press4647# Wait48agent-browser wait @e1 # Wait for element49agent-browser wait --load networkidle # Wait for network idle5051# Capture52agent-browser screenshot # Screenshot53agent-browser screenshot --full # Full page54```5556## Ref Lifecycle (Important)5758Refs (`@e1`, `@e2`, etc.) are invalidated when the page changes. Always re-snapshot after clicking links/buttons that navigate, form submissions, or dynamic content loading.5960## Deep-Dive Documentation6162| Reference | When to Use |63|-----------|-------------|64| [references/commands.md](references/commands.md) | Full command reference with all options |65| [references/snapshot-refs.md](references/snapshot-refs.md) | Ref lifecycle, invalidation rules, troubleshooting |66| [references/session-management.md](references/session-management.md) | Parallel sessions, state persistence, concurrent scraping |67| [references/authentication.md](references/authentication.md) | Login flows, OAuth, 2FA handling, state reuse |68| [references/video-recording.md](references/video-recording.md) | Recording workflows for debugging and documentation |69| [references/proxy-support.md](references/proxy-support.md) | Proxy configuration, geo-testing, rotating proxies |70| [references/common-patterns.md](references/common-patterns.md) | Form submission, auth, data extraction, parallel sessions, iOS simulator |71| [references/semantic-locators.md](references/semantic-locators.md) | Alternatives to refs |72| [references/javascript-evaluation.md](references/javascript-evaluation.md) | eval rules, --stdin/-b explanation |7374## Ready-to-Use Templates7576| Template | Description |77|----------|-------------|78| [templates/form-automation.sh](templates/form-automation.sh) | Form filling with validation |79| [templates/authenticated-session.sh](templates/authenticated-session.sh) | Login once, reuse state |80| [templates/capture-workflow.sh](templates/capture-workflow.sh) | Content extraction with screenshots |