The BrowserToolkit gives agents full browser automation via Playwright CDP mode. It drives Chrome directly through the Chrome DevTools Protocol — native async, role-based element refs (Documentation Index
Fetch the complete documentation index at: https://docs.definable.ai/llms.txt
Use this file to discover all available pages before exploring further.
e1, e2, e3), AI-friendly errors, and self-healing connections.
Installation
Quick Start
Connection Modes
BrowserToolkit supports three connection modes, selected by theBrowserConfig you pass in.
Fresh Chrome (Default)
Launches a new ephemeral Chrome instance. Cookies and storage are discarded when the toolkit shuts down.Persistent Profile
Launch Chrome with a persistent user data directory. Cookies, localStorage, and logged-in sessions survive between runs.CDP Attach
Attach to an already-running Chrome instance via its remote debugging port. No new browser window is opened — the agent controls your existing browser.BrowserConfig Reference
WebSocket or HTTP URL of an existing Chrome CDP endpoint. When set, no new browser is launched.
Run Chrome without a visible window.
Path to a Chrome user data directory for session persistence.
Enable anti-detection flags (
--disable-blink-features=AutomationControlled).Disable Chrome sandbox. Required in Docker/CI environments.
Proxy server in
"host:port" or "user:pass@host:port" format.Override the browser’s User-Agent string.
Browser locale code, e.g.
"en-US", "fr", "zh-CN".Browser timezone override, e.g.
"America/New_York".Browser viewport width in pixels.
Browser viewport height in pixels.
Default per-operation timeout in seconds.
Path to Chrome/Brave/Edge binary. Auto-detected if not set.
Additional Chrome CLI flags.
Element Refs — The Key Innovation
Agents interact with semantic element refs instead of brittle CSS selectors. After callingbrowser_snapshot(), every interactive element gets a ref like e1, e2, e3:
browser_click("button.submit") is also valid. The ref system auto-detects which you’re using.
Tools Reference
All 55 tools are grouped by category below. Every tool name is prefixed withbrowser_.
Navigation (4 tools)
| Tool | Description |
|---|---|
browser_navigate | Navigate to a URL (must include scheme, e.g. https://) |
browser_go_back | Navigate to the previous page in history |
browser_go_forward | Navigate forward in history |
browser_refresh | Reload the current page |
Page State (7 tools)
| Tool | Description |
|---|---|
browser_get_url | Return the current page URL |
browser_get_title | Return the current page title |
browser_get_text | Return visible text of an element (default: body) |
browser_get_source | Return page HTML source (capped at 20,000 chars) |
browser_get_attribute | Return an HTML attribute value on an element |
browser_is_visible | Check if an element is currently visible |
browser_get_page_info | Situational snapshot: URL, title, scroll position, element counts |
Perception (2 tools)
| Tool | Description |
|---|---|
browser_snapshot | Accessibility-tree view with role-based refs (e1, e2, e3) for every interactive element |
browser_screenshot | Take a screenshot and save to a file |
Interaction (15 tools)
| Tool | Description |
|---|---|
browser_click | Click an element by ref or CSS selector |
browser_click_if_visible | Click only if the element is visible (safe for popups) |
browser_click_by_text | Click the first element whose visible text contains the given string |
browser_type | Clear an input and type text into it |
browser_type_slowly | Type with human-like 75ms delays (avoids bot detection) |
browser_press_keys | Send keystrokes to a specific element (requires selector) |
browser_press_key | Press a key on the focused element (no selector needed) |
browser_clear_input | Clear an input field or textarea |
browser_select_option | Select an option from a <select> dropdown by visible text |
browser_hover | Hover over an element (reveals dropdowns, tooltips) |
browser_drag | Drag one element to another via Playwright native drag |
browser_fill_form | Batch fill a form: [{ref, type, value}, ...] |
browser_set_value | Set an element’s value directly (works for sliders, range inputs) |
browser_set_input_files | Set files on a file input element |
browser_execute_js | Execute JavaScript in the page context |
Scrolling (3 tools)
| Tool | Description |
|---|---|
browser_scroll_down | Scroll down by N screen-heights (default 3) |
browser_scroll_up | Scroll up by N screen-heights (default 3) |
browser_scroll_to | Scroll until an element is in view |
Waiting (4 tools)
| Tool | Description |
|---|---|
browser_wait | Pause for N seconds (use after page loads) |
browser_wait_for_element | Wait up to N seconds for an element to appear |
browser_wait_for_text | Wait up to N seconds for text to appear inside a selector |
browser_wait_for | Unified wait: text, text_gone, selector, url, load_state, or JS function |
DOM Manipulation (2 tools)
| Tool | Description |
|---|---|
browser_highlight | Flash a gold border around an element for 2 seconds |
browser_remove_elements | Remove all elements matching a selector from the DOM |
Forms & Checkboxes (3 tools)
| Tool | Description |
|---|---|
browser_is_checked | Check if a checkbox or radio is checked |
browser_check | Check a checkbox or radio (idempotent) |
browser_uncheck | Uncheck a checkbox (idempotent) |
Cookies (3 tools)
| Tool | Description |
|---|---|
browser_get_cookies | Return all cookies as a JSON array |
browser_set_cookie | Set a cookie on the current domain |
browser_clear_cookies | Delete all cookies for the session |
Storage (2 tools)
| Tool | Description |
|---|---|
browser_get_storage | Get a value from localStorage or sessionStorage |
browser_set_storage | Set a key/value pair in localStorage or sessionStorage |
Tabs (4 tools)
| Tool | Description |
|---|---|
browser_open_tab | Open a new tab, optionally navigating to a URL |
browser_close_tab | Close the currently active tab |
browser_get_tabs | Return the number of open tabs |
browser_switch_to_tab | Switch to a tab by zero-based index |
Output (1 tool)
| Tool | Description |
|---|---|
browser_print_to_pdf | Save the current page as PDF |
Dialogs (1 tool)
| Tool | Description |
|---|---|
browser_handle_dialog | Accept or dismiss a browser dialog (alert/confirm/prompt) |
Browser State (1 tool)
| Tool | Description |
|---|---|
browser_set_geolocation | Override GPS coordinates via CDP |
Diagnostics (3 tools)
| Tool | Description |
|---|---|
browser_get_console | Return captured browser console messages (with level filter) |
browser_get_errors | Return captured browser page errors |
browser_get_network | Return captured network requests (with URL filter) |
Usage with Agent
The toolkit follows theAsyncLifecycleToolkit protocol. Use async with for automatic startup and shutdown: