agent-browser 101: AI-First Browser Automation CLI
Install, basic commands, Accessibility Tree ref-based element selection, and proxy configuration for scraping.
16Yun Engineering TeamMay 3, 20261 min read
Installation
Global Install (recommended)
npm install -g agent-browser
agent-browser install # Auto-downloads Chrome for Testing on first run
macOS Homebrew
brew install agent-browser
agent-browser install
Verify
agent-browser doctor
Fastest Browser Automation Workflow
# 1. Open a page
agent-browser open https://example.com
# 2. Get page structure (Accessibility Tree)
agent-browser snapshot
# 3. Operate elements by ref
agent-browser click @e2
agent-browser fill @e3 "user@example.com"
# 4. Screenshot
agent-browser screenshot page.png
# 5. Close
agent-browser close
Zero code. All CLI.
Snapshot + Ref Selection
The key difference from traditional browser automation tools:
| Method | Tool | Principle | Stability |
|---|---|---|---|
| CSS selector | Playwright/Puppeteer | DOM classes/IDs | Breaks on redesign |
| XPath | Selenium | DOM path | Breaks on structure change |
| Accessibility Ref | agent-browser | Accessibility tree | Stable if semantics stay |
Workflow
# Get snapshot with refs
agent-browser snapshot
# [1] @e1 heading "Welcome"
# [2] @e2 button "Sign In"
# [3] @e3 textbox "Email"
# [4] @e4 textbox "Password"
# [5] @e5 button "Submit"
# Operate by ref
agent-browser click @e2
agent-browser fill @e3 "my@email.com"
agent-browser fill @e4 "mypassword"
agent-browser click @e5
Traditional Selectors Also Work
agent-browser click "#submit"
agent-browser find role button click --name "Submit"
Quick Command Reference
| Category | Command | Description |
|---|---|---|
| Navigate | open <url> | Open a URL |
| Explore | snapshot | Get Accessibility Tree + refs |
| Click | click <sel> | Click an element |
| Fill | fill <sel> <text> | Clear and fill |
| Type | type <sel> <text> | Append text |
| Screenshot | screenshot [path] | Take screenshot |
| Screenshot | screenshot --full | Full page screenshot |
| Screenshot | screenshot --annotate | Annotated with numbered labels |
| JS | eval <js> | Execute JavaScript |
| Get | get title / get url | Get title/URL |
| Get | get text <sel> | Get element text |
| Wait | wait <ms> / wait <sel> | Wait |
| Close | close | Close browser |
Using with Proxies
export HTTP_PROXY=http://user:pass@proxy.16yun.cn:8888
export HTTPS_PROXY=http://user:pass@proxy.16yun.cn:8888
agent-browser open https://example.com
Verify Proxy
agent-browser open https://httpbin.org/ip
agent-browser get text body
Recommended 16Yun Product Config
| Scenario | Proxy Product | Setup |
|---|---|---|
| Single test | Crawler Proxy | HTTP_PROXY env var |
| Batch scraping | API Proxy | Switch proxy per session |
| Long-running | Dedicated Proxy | Fixed IP + session persistence |
CLI + AI Agent Workflow
agent-browser batch \
"open https://example.com/login" \
"fill @e3 admin@example.com" \
"fill @e4 password123" \
"click @e5"
# Natural language control
agent-browser chat "open example.com, log in, and screenshot the dashboard"
Need an enterprise proxy plan?
We can tailor architecture to your target domains, concurrency, and reliability goals.