π€― LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.
agent-browser CLI reference
Generic reference for the agent-browser CLI β automate Chromium-based apps
(Electron, Chrome, web) via Chrome DevTools Protocol. This is the shared driver
for Web and Electron evidence; native surfaces use their own tools. Per-surface
setup, authentication, capture, and boundary decisions remain in the selected
surface guide.
Contents
- Core workflow
- Essential commands
- Batch execution
- JavaScript evaluation
- Connect to an existing browser or app
- Gotchas
Install via npm i -g agent-browser, brew install agent-browser, or
cargo install agent-browser. Run agent-browser install to download Chrome.
Run agent-browser upgrade to update.
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 "[email protected]"
agent-browser fill @e2 "password123"
agent-browser click @e3
agent-browser wait --load networkidle
agent-browser snapshot -i # check result
Command chaining
agent-browser open https://example.com && agent-browser wait --load networkidle && agent-browser snapshot -i
Use && when you don't need to read intermediate output. Run commands separately
when you need to parse output first (e.g. snapshot to discover refs, then interact).
Essential commands
# Navigation
agent-browser open <url> # Navigate (aliases: goto, navigate)
agent-browser close # Close browser
agent-browser close --all # Close all active sessions
# Snapshot
agent-browser snapshot -i # Interactive elements with refs (recommended)
agent-browser snapshot -i -C # Include contenteditable (rich text editors)
agent-browser snapshot -s "#selector" # Scope to CSS selector
# Interaction (use @refs from snapshot)
agent-browser click @e1 # Click element
agent-browser click @e1 --new-tab # Click and open in new tab
agent-browser fill @e2 "text" # Clear and type text (NOT for contenteditable)
agent-browser type @e2 "text" # Type without clearing (use for chat inputs)
agent-browser select @e1 "option" # Select dropdown option
agent-browser check @e1 # Check checkbox
agent-browser press Enter # Press key
agent-browser keyboard type "text" # Type at current focus (no selector)
agent-browser scroll down 500 # Scroll page
agent-browser scroll down 500 --selector "div.content" # Scroll within container
# Get information
agent-browser get text @e1 # Get element text
agent-browser get url # Get current URL
agent-browser get title # Get page title
# Wait
agent-browser wait @e1 # Wait for element
agent-browser wait --load networkidle # Wait for network idle
agent-browser wait --url "**/page" # Wait for URL pattern
agent-browser wait 2000 # Wait milliseconds
agent-browser wait --text "Welcome" # Wait for text to appear
agent-browser wait --fn "!document.body.innerText.includes('Loading...')" # Wait for condition
agent-browser wait "#spinner" --state hidden # Wait for element to disappear
# Downloads
agent-browser download @e1 ./file.pdf # Click an element to trigger a download
agent-browser wait --download ./output.zip # Wait for a download to finish
# Diff (compare page states)
agent-browser diff snapshot # Current vs the last snapshot
agent-browser diff screenshot --baseline before.png # Visual pixel diff
agent-browser diff url <url1> <url2> # Compare two pages
# Network (key for full-stack evidence)
agent-browser network requests # Inspect tracked requests
agent-browser network requests --type xhr,fetch # Filter by resource type
agent-browser network requests --method POST # Filter by HTTP method
agent-browser network har start # Start HAR recording
agent-browser network har stop ./capture.har # Stop and save HAR file
# Viewport & device emulation
agent-browser set viewport 1920 1080 # Set viewport size (default 1280x720)
agent-browser set viewport 1920 1080 2 # 2x retina
agent-browser set device "iPhone 14" # Emulate device (viewport + UA)
# Capture (evidence!)
agent-browser screenshot ./shot.png # Screenshot to a path
agent-browser screenshot --full # Full page screenshot
agent-browser screenshot --annotate # Annotated screenshot with numbered element labels
agent-browser pdf output.pdf # Save as PDF
# Dialogs (alert, confirm, prompt, beforeunload)
agent-browser dialog accept # Accept dialog
agent-browser dialog accept "input" # Accept prompt dialog with text
agent-browser dialog dismiss # Dismiss/cancel dialog
agent-browser dialog status # Check if dialog is open
Batch execution
echo '[
["open", "https://example.com"],
["snapshot", "-i"],
["click", "@e1"],
["screenshot", "result.png"]
]' | agent-browser batch --json
Semantic locators (alternative to refs)
agent-browser find text "Sign In" click
agent-browser find label "Email" fill "[email protected]"
agent-browser find role button click --name "Submit"
agent-browser find placeholder "Search" type "query"
agent-browser find testid "submit-btn" click
JavaScript evaluation (eval)
Use eval to read app state, dump DOM/HTML, or assert computed values for text /
dom_snapshot evidence.
# Simple expressions
agent-browser eval 'document.title'
# Complex JS: use --stdin with heredoc (RECOMMENDED β avoids shell quoting bugs)
agent-browser eval --stdin << 'EVALEOF'
JSON.stringify(
Array.from(document.querySelectorAll("img"))
.filter(i => !i.alt)
.map(i => ({ src: i.src.split("/").pop(), width: i.width }))
)
EVALEOF
# Base64 encoding (avoids all shell escaping issues)
agent-browser eval -b "$(echo -n 'document.title' | base64)"
If the app under test exposes a global state object (a store, a debug handle), eval is how you read it for assertion. Don't assume a specific global name β discover it from the app you are verifying.
Ref lifecycle
Refs (@e1, @e2, β¦) are invalidated when the page changes. Always re-snapshot
after clicking links/buttons that navigate, form submissions, or dynamic content
loading. After a hot-reload (HMR) during dev, refs also break β re-snapshot.
Annotated screenshots (vision mode)
agent-browser screenshot --annotate
# Output includes the image path and a legend:
# [1] @e1 button "Submit"
# [2] @e2 link "Home"
agent-browser click @e2 # click using ref from annotated screenshot
Parallel sessions
agent-browser --session site1 open https://site-a.com
agent-browser --session site2 open https://site-b.com
agent-browser session list
A named --session reuses the same running browser and its cookies + localStorage
across commands. Each session is a separate daemon plus browser that outlives
the calling process: close it with agent-browser --session <name> close when
the run ends, and export AGENT_BROWSER_IDLE_TIMEOUT_MS (disabled by default)
so an abandoned session shuts itself down. Long runs should also recycle: close
and reopen the session with --restore after a stretch of heavy captures, rather
than letting one browser accumulate memory for the whole round. See
resource-guard.md for the host-level backstop. See
../surfaces/web.md. To save and restore that
state across browser restarts, also enable --restore with a stable session ID:
agent-browser --session site1 --restore open https://site-a.com
Use the same session ID and --restore on later launches. See
auth-web.md for manual state files and persistent profiles, and the
official session persistence guide
for restore behavior.
Connect to an existing browser / app
agent-browser --auto-connect snapshot # Auto-discover a running Chrome
agent-browser --cdp 9222 snapshot # Explicit CDP port (Electron apps, see ../surfaces/electron.md)
Cloud providers & engine selection
agent-browser -p browserbase open example.com # run against a cloud browser
agent-browser --engine lightpanda open example.com # 10x faster, 10x less memory
Providers: agentcore, browserbase, browserless, browseruse, kernel.
Gotchas
- Daemon can get stuck β if your session hangs, close it with
agent-browser --session <name> closeand reopen it.close --all/pkill -f agent-browseralso kill other runs' sessions; use them only when no other agent is driving a browser. - Sessions leak when not closed β daemons never exit on their own unless
AGENT_BROWSER_IDLE_TIMEOUT_MSis set, andsession listcan miss a daemon whose run already died. Reap by pid, not only by session name, and keep the resource guard running. Withstop-owned, it stops only this run's owned processes when the platform-specific stop conditions are met; swap usage alone does not trigger a stop on macOS. - HMR invalidates everything β after code changes during dev, refs break; re-snapshot or restart.
snapshot -idoesn't find contenteditable β usesnapshot -i -Cfor rich text editors;filldoesn't work on contenteditable, usetype.- Screenshots written to a path are easiest β
agent-browser screenshot ./proof/x.pngthen upload that path; with no path they land in~/.agent-browser/tmp/screenshots/. - Dialogs block all commands β if commands time out, check
agent-browser dialog status. - Default timeout is 25s β override with
AGENT_BROWSER_DEFAULT_TIMEOUT(ms) or use explicit waits. - Shell quoting corrupts eval β use
eval --stdin <<'EVALEOF'for complex JS.