browser
The command Agents use to read, capture and drive web pages in a real cloud browser.
browser gives an Agent a real Chrome browser in the cloud. It can turn a page into Markdown, a PNG or a PDF in one command, or open a live session that keeps its page and cookies between commands so the Agent can click, type and read its way through a site.
Where it runs
The same command is available to Agents on a cloud Team and on a Mac Team. In both cases the browser itself runs in the cloud, not on the Mac. Sign-in comes from the Agent’s environment, so there is nothing to set up. The command needs curl and jq, which the environment provides. See Choose where your Agents run for the two kinds of Team.
Sessions belong to the Team: every Agent of the Team shares one set of named sessions, and they keep their browsers apart by the names they choose.
Synopsis
browser scrape <url> [options]
browser screenshot <url> [-o FILE] [options]
browser pdf <url> [-o FILE] [options]
browser start [--session NAME] [--no-stealth]
browser <command> [--session NAME] [arguments] [options]
browser stop [--session NAME | --all]
browser status [ID]
browser --help
browser <command> --help
browser --version--session NAME can go anywhere after the command name (browser click --session signup e3, not browser --session signup click e3). Without it, a command addresses the Team’s one unnamed session. A name is letters, digits, - and _, starting with a letter or digit, up to 32 characters.
One-shot commands
These need no session. Each opens a page, captures it and cleans up after itself. Passing --session to them is an error.
| Command | Prints or writes |
|---|---|
browser scrape <url> |
The rendered page as Markdown, on stdout. |
browser screenshot <url> |
The rendered page as a PNG file, screenshot.png by default. Prints Saved to <path>. |
browser pdf <url> |
The rendered page as a PDF file, page.pdf by default. Prints Saved to <path>. |
screenshot and pdf are one-shot when their first argument starts with http:// or https://. Without an address they capture the current page of a session instead (see Session commands).
| Option | Applies to | Value | Meaning |
|---|---|---|---|
-o, --output |
screenshot, pdf |
A path | Where to save the file. |
-d, --delay |
all three | Milliseconds | Waits this long before capturing, so videos and animations can settle. |
-f, --full-page |
screenshot |
— | Captures the full scrollable page. |
--format |
scrape |
Comma-separated: html, readability, cleaned_html, markdown |
The output formats to return. |
--pdf, --screenshot |
scrape |
— | Also include a PDF or a screenshot in the response. |
--json |
all three | — | Prints JSON instead of text. For screenshot and pdf: {"success": true, "data": {"path": "<file>", "url": "<address>"}}. |
Sessions
A session is a live browser that keeps its pages, cookies and sign-in state between commands.
browser start --session NAMEopens it. Starting a name that is already open replaces that session.- Commands with the same
--session NAMEact on it. browser stop --session NAMEcloses it.
browser start prints:
Browser session "signup" started. Pass --session signup to every command for it. It closes after 3 min without commands, and 15 min after start no matter what — run `browser stop --session signup` when done.Session lifetime
The lifetime is fixed and cannot be extended:
- A session closes by itself after 3 minutes without a command. Every command resets this timer.
- A session closes 15 minutes after it started, whatever it is doing.
- When a session closes, its pages, cookies and sign-in state are gone.
browser startopens a fresh, blank browser; an old session cannot be resumed.
The Team can hold only a limited number of sessions at once, so stop a session as soon as it is no longer needed. browser status shows how many of the Team’s slots are in use.
Start options
| Option | Default | Meaning |
|---|---|---|
--session NAME |
The unnamed session | The session to open. |
--no-stealth |
Off | Opens the session without human-like pacing of clicks and typing and without automatic CAPTCHA solving. Input is instant, but a CAPTCHA will not be solved. |
browser start takes no other arguments. By default a session paces its input like a person and solves CAPTCHAs on its own; browser captcha status shows the progress while one is being solved.
Artifact pages
A session that browser start opens sees an artifact’s link, https://airbuild.page/<artifact-id>, the way a person in the Agent’s Team sees it. browser open on the link shows the page with AirBuild’s bar above it, and that includes artifacts only the Team can view, not only those open to anyone with the link. There is nothing to set up, and browser start says nothing about it.
This is best effort. If the Team’s view can’t be added to a new session, the session still starts, with no message about it, and opens only the artifacts that anyone with the link can view. The one-shot scrape, screenshot and pdf of an address use no session, so they also open only those.
The link is the one to give people, in a message, on a card or anywhere else. See Artifacts.
Session commands
Every command in this table takes --session NAME. Element arguments are a ref from the latest snapshot (such as e5) or a CSS selector.
| Command | Arguments and options | What it does |
|---|---|---|
open |
<url> · --wait-until load, domcontentloaded or networkidle |
Goes to an address. |
back, forward, reload |
— | Browser history and reload. |
snapshot |
-i, --interactive (only interactive elements) · -c, --compact (only lines with refs or values, and their ancestors) · -d, --max-depth N |
Prints the page’s accessibility tree with element refs (e1, e2, …). Refs change when the page changes; take a new snapshot after navigating. |
click |
<element> · --count N (2 for a double click) |
Clicks an element. |
dblclick, hover, focus, clear |
<element> |
Double-clicks, hovers, focuses or clears an element. |
fill |
<element> <value> |
Replaces the field’s value. |
type |
<element> <text> · --clear · --delay MS (between keys, at most 1000) |
Types key by key, adding to the current value. |
press |
<key> |
Presses a key or chord: Enter, Escape, Tab, Control+a. |
keydown |
<key> |
Holds a key down until keyup: Shift, Control, ArrowDown. See Holding keys. |
keyup |
<key> |
Releases a key held with keydown. |
selectall |
<element> |
Selects all the text in an input or text area, so the next press or type acts on it. |
select |
<element> <value>… |
Picks options in a <select> by value or label. |
check, uncheck |
<element> |
Ticks or clears a checkbox. |
scroll |
[DIRECTION] [pixels] (up, down, left, right) · -s, --selector <element> |
Scrolls the page, or one element. Defaults: down, 300 pixels. |
drag |
<source> <target> |
Drags one element onto another. |
upload |
<element> <file>… |
Puts local files into a file input. |
mouse |
ACTION [x] [y] (move, down, up, click, wheel) · --button left, right or middle · --clicks 1–3 · --dx, --dy |
Mouse input at CSS-pixel coordinates of the visible page, for canvases and maps. |
get |
title, url, text <el>, html <el>, markdown [el], value <el>, attr <el> <name>, count <selector>, box <el> |
Reads one thing off the page. See Reading the page. |
is |
STATE <element> (visible, enabled, checked) |
Checks an element’s state. |
find |
<value> · --by css, role, text, label, placeholder, alt, title or testid (default css) · --name (with --by role) · --exact |
Finds elements and prints their refs. |
content |
— | Prints the page’s full HTML. |
eval |
<script> |
Runs JavaScript in the page and prints its value. |
screenshot |
-o FILE (default screenshot.png) · -f, --full-page · --selector <element> · --format png, jpeg or webp · --quality 0–100 |
Captures the session’s current page. |
pdf |
-o FILE (default page.pdf) · --landscape · --print-background |
Saves the session’s current page as a PDF. |
wait |
[MS] (at most 30000) · -t, --text · --selector <element> · --state visible, hidden, attached or detached · -u, --url (* matches anything) · -l, --load-state load, domcontentloaded or networkidle · --timeout MS (default 30000, at most 50000) |
Waits for a fixed time, text, an element, an address or a load state. |
wait --download |
-o FILE (default: the file’s own name in the current folder) |
Waits for a download a click started, and saves it. |
tab |
list · new [url] · switch <id> (such as t2) · close [id] |
Lists, opens, switches and closes tabs. |
batch |
"<command>" "<command>" … |
Runs several commands in one call, in order, stopping at the first failure: browser batch "fill e3 'New York'" "click e5". |
captcha |
status · solve |
Shows whether a CAPTCHA is being solved, or asks for one to be solved. |
set |
See Browser settings | Settings held on the browser for every tab. |
cookies |
See Cookies | The session’s cookies. |
dialog |
See Page dialogs | Answers an alert, confirm or prompt. |
stop |
-a, --all |
Closes the session, or every session. |
status |
[ID] |
Without an id: the open sessions and the Team’s slots. With an id (such as x-7): waits for an action that was still running when its command returned; the message that said so gives the id. |
cancel |
<ID> (such as x-7) |
Stops an action that was still running when its command returned, instead of waiting for it with status. See Stopping a running action. |
Add --diff to any action and it prints what the action changed on the page instead of needing a fresh snapshot. Add --json to any command for JSON output.
browser status prints one line per session and the slots line:
Session "signup" <session-id> — live.
Team browser slots in use: 1 of <limit>.Reading the page
browser get reads one thing off the session’s current page and prints it on stdout. Element arguments are a ref from the latest snapshot (such as e5) or a CSS selector. A CSS selector must match one element; for several matches, use a more specific selector or a ref.
| Command | Arguments | Prints |
|---|---|---|
browser get title |
— | The page’s title: Example Domain. |
browser get url |
— | The page’s address: https://example.com/. |
browser get text <element> |
An element | The element’s visible text. |
browser get html <element> |
An element | The element’s inner HTML. |
browser get markdown [element] |
An element, optional | The main content of the element as Markdown; without an element, of the whole page. |
browser get value <element> |
An input or text area | The field’s current value. Prints an empty line when the field is empty or the element is not a field. |
browser get attr <element> <name> |
An element and an attribute name | The attribute’s value: browser get attr e12 href. |
browser get count <selector> |
A ref or CSS selector | How many elements match: 6. |
browser get box <element> |
An element | The element’s position and size in CSS pixels, as JSON with x, y, width and height. |
Every get command takes these options:
| Option | Default | Meaning |
|---|---|---|
--session NAME |
The unnamed session | The session to read from. |
--diff |
Off | Prints what the command changed on the page. |
--json |
Off | Prints JSON instead of text. The value is under data.results[0].value, and the page’s title and address under data.page. |
Errors from get exit with code 1:
| Message | What to do |
|---|---|
Error: element_not_found: No element matches css="…". |
Check the selector, or take a snapshot and use a ref. |
Error: invalid_argument: css="…" matches N elements. … |
Use a more specific selector, or a ref from a snapshot. get count is the one command that takes a selector with several matches. |
Error: stale_ref: Ref e1 is not known. Take a new snapshot. … |
The page changed since the snapshot. Run browser snapshot -i and use the new ref. |
browser get title --session shop
browser get attr --session shop e12 href
browser get count --session shop "ul.results li"
browser get markdown --session shopget title
Prints the title of the session’s current page. Takes no arguments, only the options above.
Prints: the title on one line, such as Example Domain.
browser get title --session shopget url
Prints the address of the session’s current page. Takes no arguments, only the options above.
Prints: the address on one line, such as https://example.com/.
browser get url --session shopget text
Prints the visible text of one element.
| Argument | What it does | Default |
|---|---|---|
<element> |
The element: a ref such as e5, or a CSS selector. Required. |
— |
Prints: the element’s visible text.
browser get text --session shop e5get html
Prints the inner HTML of one element.
| Argument | What it does | Default |
|---|---|---|
<element> |
The element: a ref such as e5, or a CSS selector. Required. |
— |
Prints: the element’s inner HTML.
browser get html --session shop e5get markdown
Prints the main content of one element, or of the whole page, as Markdown.
| Argument | What it does | Default |
|---|---|---|
[element] |
The element: a ref such as e5, or a CSS selector. |
The whole page |
Prints: the content as Markdown.
browser get markdown --session shopget value
Prints the current value of an input or text area.
| Argument | What it does | Default |
|---|---|---|
<element> |
The field: a ref such as e5, or a CSS selector. Required. |
— |
Prints: the field’s value; an empty line when the field is empty or the element is not a field.
browser get value --session shop e3get attr
Prints the value of one attribute of an element.
| Argument | What it does | Default |
|---|---|---|
<element> |
The element: a ref, or a CSS selector. Required. | — |
<name> |
The attribute’s name, such as href. Required. |
— |
Prints: the attribute’s value.
browser get attr --session shop e12 hrefget count
Prints how many elements match.
| Argument | What it does | Default |
|---|---|---|
<selector> |
A ref such as e5, or a CSS selector. Required. Unlike the other get commands, the selector may match several elements. |
— |
Prints: the number, such as 6.
browser get count --session shop "ul.results li"get box
Prints an element’s position and size.
| Argument | What it does | Default |
|---|---|---|
<element> |
The element: a ref such as e5, or a CSS selector. Required. |
— |
Prints: JSON with x, y, width and height, in CSS pixels.
browser get box --session shop e5Holding keys
press presses and releases a key at once. keydown holds a key until keyup releases it, for input that needs a key held while something else happens, such as Shift held during clicks to select a range. Key names are the same as for press (Shift, Control, Alt, Meta, ArrowDown, Enter). Both print nothing on success and take --session NAME, --diff and --json.
selectall <element> selects all the text in an input or text area. It takes the same options.
browser keydown --session list Shift
browser click --session list e8
browser click --session list e14
browser keyup --session list Shift
browser selectall --session list e3
browser press --session list Backspacekeydown
Holds a key down until keyup releases it.
| Argument or option | What it does | Default |
|---|---|---|
<key> |
The key to hold, such as Shift, Control or ArrowDown. Required. |
— |
--session NAME |
The session to act on. | The unnamed session |
--diff |
Prints what the command changed on the page. | Off |
--json |
Prints JSON instead of text. | Off |
Prints nothing on success.
browser keydown --session list Shiftkeyup
Releases a key held with keydown.
| Argument or option | What it does | Default |
|---|---|---|
<key> |
The key to release, such as Shift, Control or ArrowDown. Required. |
— |
--session NAME |
The session to act on. | The unnamed session |
--diff |
Prints what the command changed on the page. | Off |
--json |
Prints JSON instead of text. | Off |
Prints nothing on success.
browser keyup --session list Shiftselectall
Selects all the text in an input or text area, so the next press or type acts on it.
| Argument or option | What it does | Default |
|---|---|---|
<element> |
The field: a ref such as e5, or a CSS selector. Required. |
— |
--session NAME |
The session to act on. | The unnamed session |
--diff |
Prints what the command changed on the page. | Off |
--json |
Prints JSON instead of text. | Off |
Prints nothing on success.
browser selectall --session list e3cancel
Stops an action that was still running when its command returned. Such a command returns early with a message that gives the action’s id, such as x-7. browser status x-7 waits for it to finish; browser cancel x-7 stops it.
| Argument or option | What it does | Default |
|---|---|---|
<ID> |
The action’s id, from the message that said it was still running. Required. | — |
--session NAME |
The session the action runs in. | The unnamed session |
--json |
Prints JSON instead of text. | Off |
If the id does not belong to an action of that session, cancel stops with Error: Execution x-7 is not known in this session. and exit code 1; check the id and the --session name.
browser cancel --session signup x-7Browser settings
browser set changes settings on the session’s browser. They apply to every tab and hold until changed or until the session closes.
| Command | Meaning | Prints |
|---|---|---|
browser set viewport <width> <height> [--mobile] [--scale N] |
Lays every tab out at this size. --mobile makes pages take touches and report themselves as a phone; --scale sets the pixel density (default 1). |
Viewport set to 393x852 (mobile). |
browser set viewport reset |
Back to the window size. | Viewport reset to the window size. |
browser set useragent <string> |
Replaces the user agent. reset (or no string) restores it. |
User agent set. |
browser set geo <latitude> <longitude> [--accuracy METERS] |
Reports this location (accuracy defaults to 1 meter). browser set geo reset removes it. |
Location set to 52.52, 13.40. |
browser set headers '<json>' |
Adds request headers from a JSON object. '{}' removes them. |
Extra request headers set. |
browser set offline on / browser set offline off |
Takes the browser offline or back online. | The browser is offline. |
Cookies
| Command | Meaning |
|---|---|
browser cookies |
Lists the session’s cookies, HttpOnly ones included, one per line: name=value domain/path HttpOnly Secure. Prints No cookies. when there are none. |
browser cookies set <name> <value> [--domain D] [--path P] [--secure] [--http-only] |
Adds a cookie. Without --domain it is for the page the session is on, so open a page first. |
browser cookies clear |
Removes all of them. Prints Cookies cleared. |
Page dialogs
A page’s alert, confirm or prompt blocks its tab until it is answered; the next command says a dialog is open.
| Command | Meaning |
|---|---|
browser dialog |
Shows the open dialog: A confirm dialog is open: "Leave this page?". Answer it with …, or No dialog is open. |
browser dialog accept [--text T] |
Presses OK. --text answers a prompt. |
browser dialog dismiss |
Presses Cancel. |
Removed commands
These commands are no longer available. Each one stops with exit code 1 and names what to use instead:
| Command | Use instead |
|---|---|
browser storage |
browser eval "localStorage.getItem('key')" to read, browser eval "localStorage.setItem('key', 'value')" to write. |
browser setvalue |
browser fill <element> <value>. |
browser scrollintoview |
browser hover <element>, which moves the mouse to the element, or browser scroll --selector <container>. |
browser eval --session shop "localStorage.getItem('cart')"storage
Removed. Read or write the page’s local storage with eval instead. browser storage stops with a message that names the replacement:
Use `browser eval "localStorage.getItem('key')"` or `browser eval "localStorage.setItem('key', 'value')"`.browser eval --session shop "localStorage.setItem('cart', '[]')"setvalue
Removed. Set a field’s value with fill instead. browser setvalue stops with a message that names the replacement:
Use `browser fill <selector> <value>`.browser fill --session signup e3 "test@example.com"scrollintoview
Removed. Bring an element into view with hover, which moves the mouse to it, or scroll its container with scroll --selector. browser scrollintoview stops with a message that names the replacement:
Use `browser hover <selector>` (it moves the mouse), or `browser scroll --selector <container>`.browser hover --session shop e12Exit codes
| Code | Meaning |
|---|---|
0 |
Success. |
2 |
The command could not run: a usage error, or the service could not be reached. For set, cookies and dialog, also no session open or the session closed. The message on stderr says which. |
| Other | The browser’s own failure for that action, such as an element that was not found, a wait that timed out, or a session that is not running or has closed. The message is on stderr. |
Errors
| Message | What to do |
|---|---|
Error: no browser session is open. Start one with browser start. |
Run browser start (with the same --session name). |
No active browser session. Start one with browser start. / Error: Session "NAME" is not running. It may have expired. Start it with browser start --session NAME. |
Run browser start --session NAME. |
Error: the browser session "NAME" has closed (3 min without commands, or 15 min after start). … |
The session reached its lifetime. Run browser start --session NAME and repeat the steps to get back to where you were. |
Error: the Team already holds N browser sessions, its limit. … |
Run browser status, stop sessions you no longer need, or try again in a minute; a forgotten session closes itself after 3 minutes without commands. |
Automatic CAPTCHA solving is unavailable right now; this session cannot pass a CAPTCHA. |
The session works, but a page that shows a CAPTCHA will stay blocked. |
Error: the browser platform is unreachable right now; try again shortly. |
Wait and run the command again. |
Error: the capture succeeded but could not be downloaded; try again. |
Run the one-shot command again. |
Error: scrape needs no session; drop --session. |
Run it without --session. The same goes for screenshot and pdf of an address. |
Error: browser start takes no arguments except --no-stealth. |
Remove the other arguments. |
Error: --session takes a name of letters, digits, - and _ (up to 32). |
Choose a shorter or simpler name. |
Error: open a page first, or name the cookie's site with --domain. |
Open a page, or pass --domain. |
Error: no dialog is open. |
There is nothing to answer; run the command again. |
| A message that the browser was refused and that the next command will work — run this one again. | Run the same command again. |
Error: unknown command 'X'. Run browser --help. |
Check the command name. |
Examples
Read a page that needs JavaScript:
browser scrape https://example.com/pricingScreenshot a page after its animation has settled:
browser screenshot https://example.com --delay 5000 -o home.pngFill in a form in a named session, then close it:
browser start --session signup
browser open --session signup https://example.com/signup
browser snapshot --session signup -i
browser fill --session signup e3 "test@example.com"
browser click --session signup e7 --diff
browser stop --session signupCheck a page at an iPhone’s size:
browser start --session mobile
browser set --session mobile viewport 393 852 --mobile --scale 3
browser open --session mobile https://example.com
browser screenshot --session mobile -o phone.png
browser stop --session mobile