Skip to main content

browser

browser.add_init_script

browser.add_init_script

Register JavaScript that runs BEFORE the page's own code, at document start, on every page opened afterwards in this identity's context. Use when browser.evaluate is too late — most often to hook window.fetch/XMLHttpRequest and capture a SPA's request bodies, which network_requests cannot show. Does NOT affect already-open pages: add the script first, then browser.open. Cannot be removed once added; it lives until the context is evicted or browser.close is called.

Arguments

ArgumentTypeRequiredDescription
identity_namestringnodefault _anon
scriptstringyes

browser.attach_identity

browser.attach_identity

Switch the page's identity by loading saved cookies + storage. Use only when switching identity mid-page; for first navigation, pass identity_name to browser.open instead.

Arguments

ArgumentTypeRequiredDescription
identity_namestringyes
page_idstringyes

browser.attach_meet

browser.attach_meet

Attach to THIS meet's bot browser and return a page_id for its live Google Meet tab. Then use the normal browser.* tools (browser.snapshot to see the page, browser.click to press a control, browser.take_screenshot, browser.evaluate, browser.console_messages, browser.network_requests) with that page_id to inspect why the bot isn't visibly joining (lobby/blocked/admitted) and to recover a stalled join. Call with no arguments from inside a meet.

Arguments

No arguments.

browser.click

browser.click

Click an element. ref is either an aria-ref token from browser.snapshot ('e7') OR a CSS selector ('button.submit'). Prefer the aria-ref token.

Arguments

ArgumentTypeRequiredDescription
page_idstringyes
refstringyes

browser.close

browser.close

Close a page opened by browser.open.

Arguments

ArgumentTypeRequiredDescription
page_idstringyes

browser.console_messages

browser.console_messages

Return console.log/warn/error events captured since the last drain. Filter by level ('log'|'info'|'warning'|'error'|'debug') and/or pattern (regex). Buffer caps at 500 entries; oldest are dropped first. Set clear=false to peek without draining.

Arguments

ArgumentTypeRequiredDescription
clearbooleannodefault True
levelstring | nullnodefault None
page_idstringyes
patternstring | nullnodefault None

browser.drag

browser.drag

Drag one element onto another. source_ref is the element to grab; target_ref is where to drop. Both are CSS selectors. Used for slider captchas, kanban, drag-and-drop uploads.

Arguments

ArgumentTypeRequiredDescription
page_idstringyes
source_refstringyes
target_refstringyes

browser.evaluate

browser.evaluate

Run JavaScript in the page context and return the result. Use for state not in the a11y tree, captcha iframe inspection, DOM events. Expression is either a plain JS value ('document.title') or a zero-arg IIFE ('(() => { … })()'). Inline any runtime values into the expression itself. Result is JSON-serialized; non-serializable values become strings. 256KB cap on output.

Arguments

ArgumentTypeRequiredDescription
expressionstringyes
page_idstringyes

browser.file_upload

browser.file_upload

Attach files to an <input type=file>. Pass either local_paths (absolute host paths) or data (list of {name, mime, base64} blobs written to /tmp). 25MB cap per file.

Arguments

ArgumentTypeRequiredDescription
dataarray | nullnodefault None
local_pathsarray | nullnodefault None
page_idstringyes
refstringyes

browser.fill

browser.fill

Fill an input or textarea with the given value. ref is either an aria-ref token from browser.snapshot ('e7') OR a CSS selector ('input[name=email]'). Prefer the aria-ref token — it's stable and matches exactly what snapshot returned.

Arguments

ArgumentTypeRequiredDescription
page_idstringyes
refstringyes
valuestringyes

browser.fill_form

browser.fill_form

Fill multiple form fields in one call. fields is a list of {ref, value} dicts. ref is a CSS selector; value is a string (text) or boolean (checkbox). Saves N round-trips vs calling browser.fill repeatedly.

Arguments

ArgumentTypeRequiredDescription
fieldsarrayyes
page_idstringyes

browser.handle_dialog

browser.handle_dialog

Respond to a pending JS dialog (alert/confirm/prompt). Pass accept=true for OK or false for Cancel. For prompt() dialogs also pass prompt_text. Dialogs are queued at page-open time; returns {pending: false} if none is waiting.

Arguments

ArgumentTypeRequiredDescription
acceptbooleanyes
page_idstringyes
prompt_textstring | nullnodefault None

browser.hover

browser.hover

Hover the mouse over an element (reveals tooltips + hover menus). ref is a CSS selector.

Arguments

ArgumentTypeRequiredDescription
page_idstringyes
refstringyes

browser.navigate_back

browser.navigate_back

Navigate back in the page's history (browser back button). Returns the new URL + title.

Arguments

ArgumentTypeRequiredDescription
page_idstringyes

browser.network_requests

browser.network_requests

List HTTP requests the page made since open or last drain. Optional filters: method (GET/POST/...), url_pattern (regex), status_min (e.g. 400 for errors). Captures up to 200 most recent requests per page.

Arguments

ArgumentTypeRequiredDescription
clearbooleannodefault False
methodstring | nullnodefault None
page_idstringyes
status_mininteger | nullnodefault None
url_patternstring | nullnodefault None

browser.open

browser.open

Open a URL in a remote browser. Saved login cookies are auto-attached when the URL domain matches a claimed browser identity. Pass identity_name to override auto-matching or force a specific identity.

Arguments

ArgumentTypeRequiredDescription
identity_namestring | nullnodefault None
urlstringyes

browser.press_key

browser.press_key

Press a keyboard key (e.g., 'Enter', 'Tab', 'Escape', 'ArrowDown') or a single character. Optional ref focuses an element first — aria-ref token from browser.snapshot ('e7') or a CSS selector.

Arguments

ArgumentTypeRequiredDescription
keystringyes
page_idstringyes
refstring | nullnodefault None

browser.resize

browser.resize

Resize the page viewport. Useful when a site serves different HTML based on viewport width (mobile vs desktop) or when an anti-bot scores risk by viewport dimensions.

Arguments

ArgumentTypeRequiredDescription
heightintegeryes
page_idstringyes
widthintegeryes

browser.select_option

browser.select_option

Pick option(s) in a native <select> dropdown. Pass value (matches the option's value attr) OR label (matches its visible text). Lists allowed for multi-select.

Arguments

ArgumentTypeRequiredDescription
labelstring | array | nullnodefault None
page_idstringyes
refstringyes
valuestring | array | nullnodefault None

browser.snapshot

browser.snapshot

Return a YAML aria_snapshot of the page DOM. Each interactive node is tagged with [ref=eN] (e.g. [ref=e7]). Pass that exact token as the ref arg to browser.click / browser.fill / browser.type / browser.press_key. Do NOT pass the role name ('combobox', 'button') as ref — only the eN token. Truncated at 32KB.

Arguments

ArgumentTypeRequiredDescription
page_idstringyes

browser.tabs

browser.tabs

Manage tabs within the same BrowserContext as page_id. action ∈ {list, switch, close, new}. For list, returns all open tab metadata; for new, returns the new tab's page_id.

Arguments

ArgumentTypeRequiredDescription
actionstringyes
page_idstringyes
tab_idstring | nullnodefault None
urlstring | nullnodefault None

browser.take_screenshot

browser.take_screenshot

Capture a PNG screenshot of the page or a specific element. Returns base64-encoded image bytes AND a file_id (persisted in DialogBrain files storage). Pass file_id straight to messages.send(attachment_file_ids=[file_id]) — do NOT call files.upload again. Use sparingly — favor browser.snapshot for structured DOM understanding.

Arguments

ArgumentTypeRequiredDescription
full_pagebooleannodefault False
inline_bytesbooleannodefault False
page_idstringyes
refstring | nullnodefault None

browser.type

browser.type

Type text into an element with per-keystroke delay (organic). Each character dispatches keydown/keypress/keyup, unlike browser.fill which replaces .value instantly. Use when the page listens to keystroke events or for typing-speed fingerprint checks. ref is an aria-ref token from browser.snapshot ('e7') or a CSS selector. delay_ms defaults to 50.

Arguments

ArgumentTypeRequiredDescription
delay_msinteger | nullnodefault 50
page_idstringyes
refstringyes
textstringyes

browser.wait_for

browser.wait_for

Wait for a selector to appear OR a navigation URL to match a glob pattern. Provide ref (selector) OR url_pattern (glob).

Arguments

ArgumentTypeRequiredDescription
page_idstringyes
refstring | nullnodefault None
timeout_msintegernodefault 10000
url_patternstring | nullnodefault None