| user-invocable | false |
| name | agent-browser |
| description | 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.
USE FOR:
- "open a website", "go to this URL", "navigate to", "打开网页", "访问这个网站"
- "fill out a form", "click a button", "submit this form", "填写表单", "点击按钮"
- "take a screenshot", "截图", "capture this page", "record this session"
- "scrape data from a page", "extract information", "抓取数据", "爬取页面"
- "test this web app", "automate browser actions", "测试网页", "iOS 模拟器测试"
- "login to a site", "automate browser actions", "自动化浏览器", "保存登录状态"
- Any task requiring programmatic web interaction
REPLACES: Manual browser interactions, Selenium scripts
REQUIRES:
- agent-browser CLI installed (`brew install agent-browser` or via npm)
- Playwright browsers installed (`agent-browser install`)
- For iOS: macOS with Xcode, Appium (`npm install -g appium && appium driver install xcuitest`)
|
| allowed-tools | Bash(agent-browser:*) |
Pattern: Tool Wrapper (Google ADK)
Browser Automation with agent-browser
When to Use
Use when the user wants to interact with any website programmatically — filling forms, clicking buttons, extracting data, taking screenshots, or testing web apps. Also the go-to tool for iOS simulator testing and video recording of browser sessions.
Don't use when: The user only needs to read text from a page (use web_fetch instead — zero token cost). For AI-autonomous task completion, prefer browser-use run "task".
Prerequisites
- Install agent-browser: check with
agent-browser --version
- Install Playwright browsers:
agent-browser install (first time only)
- For iOS testing: macOS + Xcode +
npm install -g appium && appium driver install xcuitest
- For proxy/geo features: configure proxy settings in agent-browser config
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
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
Essential Commands
agent-browser open <url>
agent-browser close
agent-browser snapshot -i
agent-browser snapshot -i -C
agent-browser snapshot -s "#selector"
agent-browser click @e1
agent-browser fill @e2 "text"
agent-browser type @e2 "text"
agent-browser select @e1 "option"
agent-browser check @e1
agent-browser press Enter
agent-browser scroll down 500
agent-browser get text @e1
agent-browser get url
agent-browser get title
agent-browser wait @e1
agent-browser wait --load networkidle
agent-browser wait --url "**/page"
agent-browser wait 2000
agent-browser screenshot
agent-browser screenshot --full
agent-browser pdf output.pdf
Common Patterns
Form Submission
agent-browser open https://example.com/signup
agent-browser snapshot -i
agent-browser fill @e1 "Jane Doe"
agent-browser fill @e2 "jane@example.com"
agent-browser select @e3 "California"
agent-browser check @e4
agent-browser click @e5
agent-browser wait --load networkidle
Authentication with State Persistence
agent-browser open https://app.example.com/login
agent-browser snapshot -i
agent-browser fill @e1 "$USERNAME"
agent-browser fill @e2 "$PASSWORD"
agent-browser click @e3
agent-browser wait --url "**/dashboard"
agent-browser state save auth.json
agent-browser state load auth.json
agent-browser open https://app.example.com/dashboard
Data Extraction
agent-browser open https://example.com/products
agent-browser snapshot -i
agent-browser get text @e5
agent-browser get text body > page.txt
agent-browser snapshot -i --json
agent-browser get text @e1 --json
Parallel Sessions
agent-browser --session site1 open https://site-a.com
agent-browser --session site2 open https://site-b.com
agent-browser --session site1 snapshot -i
agent-browser --session site2 snapshot -i
agent-browser session list
Visual Browser (Debugging)
agent-browser --headed open https://example.com
agent-browser highlight @e1
agent-browser record start demo.webm
Local Files (PDFs, HTML)
agent-browser --allow-file-access open file:///path/to/document.pdf
agent-browser --allow-file-access open file:///path/to/page.html
agent-browser screenshot output.png
iOS Simulator (Mobile Safari)
agent-browser device list
agent-browser -p ios --device "iPhone 16 Pro" open https://example.com
agent-browser -p ios snapshot -i
agent-browser -p ios tap @e1
agent-browser -p ios fill @e2 "text"
agent-browser -p ios swipe up
agent-browser -p ios screenshot mobile.png
agent-browser -p ios close
Requirements: macOS with Xcode, Appium (npm install -g appium && appium driver install xcuitest)
Real devices: Works with physical iOS devices if pre-configured. Use --device "<UDID>" where UDID is from xcrun xctrace list devices.
Ref Lifecycle (Important)
Refs (@e1, @e2, etc.) are invalidated when the page changes. Always re-snapshot after:
- Clicking links or buttons that navigate
- Form submissions
- Dynamic content loading (dropdowns, modals)
agent-browser click @e5
agent-browser snapshot -i
agent-browser click @e1
Semantic Locators (Alternative to Refs)
When refs are unavailable or unreliable, use semantic locators:
agent-browser find text "Sign In" click
agent-browser find label "Email" fill "user@test.com"
agent-browser find role button click --name "Submit"
agent-browser find placeholder "Search" type "query"
agent-browser find testid "submit-btn" click
Quick Start
agent-browser open https://example.com/form
agent-browser snapshot -i
agent-browser fill @e1 "user@example.com"
agent-browser click @e2
agent-browser wait --load networkidle
agent-browser screenshot result.png
Examples
Example 1: Fill and Submit a Form
User says: "Fill out the contact form on example.com with my email"
Steps:
agent-browser open https://example.com/contact
agent-browser snapshot -i
agent-browser fill @e1 "user@example.com"
agent-browser fill @e2 "Hello, I have a question."
agent-browser click @e3
agent-browser wait --load networkidle
agent-browser snapshot -i
Output: Snapshot showing confirmation message
Reply: "Done! The form has been submitted. The page now shows a confirmation message."
Error Handling
| Error | Cause | Solution |
|---|
Error: Browser not found | Playwright not installed | Run agent-browser install to install browsers |
@e1 ref not found | Page changed, refs invalidated | Run agent-browser snapshot -i again to get fresh refs |
Navigation timeout | Page takes too long to load | Use agent-browser wait --load networkidle with longer timeout |
Element not clickable | Element hidden or off-screen | Use agent-browser scroll down 500 then retry |
appium: command not found | Appium not installed for iOS | Run npm install -g appium && appium driver install xcuitest |
Session expired | Browser session closed | Re-run agent-browser open <url> to start fresh |
Deep-Dive Documentation
Ready-to-Use Templates
./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