Overview
Headless browser automation via CLI. Supports sessions, snapshots (accessibility tree + refs), and semantic interaction.
Quick Start
agent-browser open example.com
agent-browser snapshot -i # Get interactive tree with refs (@e1)
agent-browser click @e2 # Click by ref
agent-browser fill @e3 "hello" # Fill input
agent-browser screenshot page.png
agent-browser close
Core Commands
- Nav:
open <url>, back, forward, reload, close
- Action:
click <sel>, dblclick, type <sel> <text>, fill, hover, focus, check, uncheck, select, drag, upload, press <key>
- View:
scroll <dir>, scrollintoview, screenshot [path], pdf
- Info:
get text|html|value|attr|title|url|count|box <sel>
- Check:
is visible|enabled|checked <sel>
- Wait:
wait <sel>|<ms>, wait --text|--url|--load|--fn
Locators & Selectors
Recommended: Use @ref from snapshot output.
Semantic: find role|text|label|placeholder|alt|title|testid <val> <action>
CSS/XPath: "#id", ".class", "text=Submit", "xpath=//button"
Snapshots (AI Vision)
Returns accessibility tree. Use -i (interactive), -c (compact), -d <n> (depth).
agent-browser snapshot -i --json -> JSON output with refs.
Advanced Features
Sessions: agent-browser --session <id> <cmd>, session list
Tabs: tab, tab new [url], tab <n>, tab close
Network: network route <url> [--abort|--body], network requests
Storage: cookies [set|clear], storage local [set|clear]
Debug: console, errors, highlight, trace start|stop, eval <js>
Settings: set viewport|device|geo|offline|media
Optimal Workflow
agent-browser open <url>
agent-browser snapshot -i --json -> Parse tree, find target @ref
agent-browser click @ref or fill @ref <val>
- Repeat snapshot to verify state.
Setup
npm install -g agent-browser && agent-browser install
1---2name: agent-browser-293description: Browser automation CLI for AI agents. Use for web scraping, testing, screenshots, form filling, and headless browser interactions.4license: Apache-2.05---6
7## Overview
8Headless browser automation via CLI. Supports sessions, snapshots (accessibility tree + refs), and semantic interaction.
9
10## Quick Start
11```bash
12agent-browser open example.com
13agent-browser snapshot -i # Get interactive tree with refs (@e1)
14agent-browser click @e2 # Click by ref
15agent-browser fill @e3 "hello" # Fill input
16agent-browser screenshot page.png
17agent-browser close
18```
19
20## Core Commands
21- **Nav**: `open <url>`, `back`, `forward`, `reload`, `close`
22- **Action**: `click <sel>`, `dblclick`, `type <sel> <text>`, `fill`, `hover`, `focus`, `check`, `uncheck`, `select`, `drag`, `upload`, `press <key>`
23- **View**: `scroll <dir>`, `scrollintoview`, `screenshot [path]`, `pdf`
24- **Info**: `get text|html|value|attr|title|url|count|box <sel>`
25- **Check**: `is visible|enabled|checked <sel>`
26- **Wait**: `wait <sel>|<ms>`, `wait --text|--url|--load|--fn`
27
28## Locators & Selectors
29**Recommended**: Use `@ref` from `snapshot` output.
30**Semantic**: `find role|text|label|placeholder|alt|title|testid <val> <action>`
31**CSS/XPath**: `"#id"`, `".class"`, `"text=Submit"`, `"xpath=//button"`
32
33## Snapshots (AI Vision)
34Returns accessibility tree. Use `-i` (interactive), `-c` (compact), `-d <n>` (depth).
35`agent-browser snapshot -i --json` -> JSON output with refs.
36
37## Advanced Features
38**Sessions**: `agent-browser --session <id> <cmd>`, `session list`
39**Tabs**: `tab`, `tab new [url]`, `tab <n>`, `tab close`
40**Network**: `network route <url> [--abort|--body]`, `network requests`
41**Storage**: `cookies [set|clear]`, `storage local [set|clear]`
42**Debug**: `console`, `errors`, `highlight`, `trace start|stop`, `eval <js>`
43**Settings**: `set viewport|device|geo|offline|media`
44
45## Optimal Workflow
461. `agent-browser open <url>`
472. `agent-browser snapshot -i --json` -> Parse tree, find target `@ref`
483. `agent-browser click @ref` or `fill @ref <val>`
494. Repeat snapshot to verify state.
50
51## Setup
52```bash
53npm install -g agent-browser && agent-browser install
54```