Open-source Python library for AI browser agents, plus Browser Use Cloud: stealth browsers and a hosted agent API.
Python ai-agentsai-toolsbrowser-agentbrowser-automationbrowser-usecdpcloud-browsercomputer-useheadless-browserllmmcpplaywrightpythonremote-browserstealth-browserweb-automationweb-scraping
more docs deduping and updating
Nick Sweeting8ab3b974e727
diff --git a/docs/customize/browser-settings.mdx b/docs/customize/browser-settings.mdxindex 8c67e01e6..0b0af41e0 100644--- a/docs/customize/browser-settings.mdx+++ b/docs/customize/browser-settings.mdx@@ -17,116 +17,151 @@ The `BrowserSession` and `BrowserProfile` classes control browser behavior and c```pythonfrom browser_use import Agent, BrowserSession, BrowserProfile-# Basic configuration-profile = BrowserProfile(+# a profile is a static, flat collection of config parameters+browser_profile = BrowserProfile(headless=False,disable_security=False)-session = BrowserSession(browser_profile=profile)+# a session is a live connection to a real browser running somewhere+browser_session = BrowserSession(+ browser_profile=browser_profile,+ **any_profile_overrides,+)++# you can optionally start a session and use it outside an Agent, otherwise Agent will automatically start itawait session.start()agent = Agent(- browser=session,- # ...+ task='your task here',+ browser_session=browser_session,+ # ... also takes BrowserSession(...) args here as a shortcut, e.g. page=page)```-## Core Settings+## `BrowserSession` Parameters-### BrowserProfile Settings+The `BrowserSession` class accepts parameters from two main sources:-- **headless** (bool | None, default: `None`)- Runs the browser without a visible UI. If None, auto-detects based on display availability.+1. **Direct BrowserSession fields** - Parameters defined directly on the `BrowserSession` class+2. **BrowserProfile fields** - Parameters that can be passed to `BrowserSession` but are actually stored in the `BrowserProfile`-- **disable_security** (bool, default: `False`)- Completely disables all basic browser security features. Allows interacting across cross-site iFrames boundaries, but very INSECURE, don't visit untrusted URLs or use cookies.+### Direct BrowserSession Parameters-- **keep_alive** (bool | None, default: `None`)- Keeps the browser alive after the agent has finished running. Useful for running multiple tasks with the same browser instance.+These parameters are defined in `browser_use/browser/session.py`:-- **user_data_dir** (str | Path | None, default: `'~/.config/browseruse/profiles/default'`)- Directory for browser profile data. Set to None to use an ephemeral profile aka incognito mode.+#### Connection Parameters-- **channel** (BrowserChannel, default: `'chromium'`)- Browser channel: `'chromium'`, `'chrome'`, `'chrome-beta'`, `'chrome-dev'`, `'chrome-canary'`, `'msedge'`, `'msedge-beta'`, `'msedge-dev'`, `'msedge-canary'`+- **wss_url** (str | None, default: `None`)+ WSS URL of the node.js playwright browser server to connect to-### Additional Settings+- **cdp_url** (str | None, default: `None`)+ CDP URL of the browser to connect to (e.g., http://localhost:9222)-- **args** (list[str], default: `[]`)- Additional command-line arguments to pass to the browser.+- **browser_pid** (int | None, default: `None`)+ PID of a running chromium-based browser process to connect to on localhost-- **proxy** (dict | None, default: `None`)- Proxy settings. Example: `{"server": "http://proxy.com:8080", "username": "user", "password": "pass"}`+#### Runtime State++- **browser_profile** (BrowserProfile, default: `BrowserProfile()`)+ BrowserProfile instance containing config for the BrowserSession++- **playwright** (Playwright | None, default: `None`)+ Playwright library object (usually auto-created)++- **browser** (Browser | None, default: `None`)+ Playwright Browser object to use (optional)++- **browser_context** (BrowserContext | None, default: `None`)+ Playwright BrowserContext object to use (optional)++- **initialized** (bool, default: `False`)+ Mark BrowserSession as already initialized (not recommended)++- **agent_current_page** (Page | None, default: `None`)+ Foreground Page that the agent is focused on++- **human_current_page** (Page | None, default: `None`)+ Foreground Page that the human is focused on++### BrowserProfile Parameters++These parameters can be passed to `BrowserSession` but are actually stored in the `BrowserProfile`. They are defined in `browser_use/browser/profile.py`:++#### Launch Settings++- **headless** (bool | None, default: `None`)+ Runs the browser without a visible UI. If None, auto-detects based on display availability.++- **channel** (BrowserChannel, default: `'chromium'`)+ Browser channel: `'chromium'`, `'chrome'`, `'chrome-beta'`, `'chrome-dev'`, `'chrome-canary'`, `'msedge'`, `'msedge-beta'`, `'msedge-dev'`, `'msedge-canary'`- **executable_path** (str | Path | None, default: `None`)Path to browser executable for custom installations.+- **args** (list[str], default: `[]`)+ Additional command-line arguments to pass to the browser.+- **env** (dict[str, str], default: `{}`)Environment variables to set when launching browser.-<Note>- For web scraping tasks on sites that restrict automated access, we recommend- using external browser or proxy providers for better reliability.-</Note>+- **chromium_sandbox** (bool, default: `not IN_DOCKER`)+ Whether to enable Chromium sandboxing (recommended unless inside Docker).-## Alternative Initialization+- **devtools** (bool, default: `False`)+ Whether to open DevTools panel automatically (only works when headless=False).-`BrowserSession` supports multiple ways to connect to browsers:+- **slow_mo** (float, default: `0`)+ Slow down actions by this many milliseconds.-### External Browser Provider (wss)+- **timeout** (float, default: `30000`)+ Default timeout in milliseconds for connecting to a remote browser.-Connect to cloud-based browser services for enhanced reliability and proxy capabilities.+#### Custom Browser Use Settings-```python-session = BrowserSession(- wss_url="wss://your-browser-provider.com/ws"-)-```+These settings are provided by browser-use, and are not default playwright settings.-- **wss_url** (str | None, default: `None`)- WebSocket URL for connecting to external browser providers (e.g., [anchorbrowser.io](https://anchorbrowser.io), steel.dev, browserbase.com, browserless.io, [TestingBot](https://testingbot.com/support/ai/integrations/browser-use)).--<Note>- This overrides local browser settings and uses the provider's configuration.- Refer to their documentation for settings.-</Note>--### External Browser Provider (cdp)+- **disable_security** (bool, default: `False`)+ Completely disables all basic browser security features. Allows interacting across cross-site iFrames boundaries, but very INSECURE, don't visit untrusted URLs or use cookies.-Connect to cloud or local Chrome instances using Chrome DevTools Protocol (CDP) for use with tools like `headless-shell` or `browserless`.+- **deterministic_rendering** (bool, default: `False`)+ Enable deterministic rendering flags for consistent screenshots.-```python-session = BrowserSession(- cdp_url="http://localhost:9222"-)-```+- **keep_alive** (bool | None, default: `None`)+ Keeps the browser alive after the agent has finished running. Useful for running multiple tasks with the same browser instance.-- **cdp_url** (str | None, default: `None`)- URL for connecting to a Chrome instance via CDP. Commonly used for debugging or connecting to locally running Chrome instances.+- **allowed_domains** (list[str] | None, default: `None`)+ List of allowed domains for navigation. If None, all domains are allowed.+ Example: `['google.com', '*.wikipedia.org']` - Here the agent will only be able to access `google.com` exactly and `wikipedia.org` + `*.wikipedia.org`.++ Glob patterns are supported:+ - `['example.com']` ✅ will match only `https://example.com/*` exactly, subdomains will not be allowed.+ It's always the most secure to list all the domains you want to give the access to explicitly w/ schemes e.g.+ `['*://google.com', 'http*://www.google.com', 'https://myaccount.google.com', 'https://mail.google.com', 'https://docs.google.com']`+ - `['*.example.com']` ⚠️ **CAUTION** this will match `https://example.com` and *all* its subdomains.+ Make sure *all* the subdomains are safe for the agent! `abc.example.com`, `def.example.com`, ..., `useruploads.example.com`, `admin.example.com`-### Local Chrome Instance (binary)+#### Browser Context Settings-Connect to your existing Chrome installation to access saved states and cookies.+- **user_data_dir** (str | Path | None, default: `'~/.config/browseruse/profiles/default'`)+ Directory for browser profile data. Set to None to use an ephemeral profile aka incognito mode.-```python-# Option 1: Use executable_path in profile-profile = BrowserProfile(- executable_path="/Applications/Google Chrome.app/Contents/MacOS/Google Chrome"-)-session = BrowserSession(browser_profile=profile)+- **accept_downloads** (bool, default: `True`)+ Whether to automatically accept all downloads.-# Option 2: Connect to running Chrome process by PID-session = BrowserSession(browser_pid=12345)-```+- **proxy** (dict | None, default: `None`)+ Proxy settings. Example: `{"server": "http://proxy.com:8080", "username": "user", "password": "pass"}`-- **executable_path** (str | Path | None, default: `None`)- Path to browser executable for custom installations.+- **permissions** (list[str], default: `['clipboard-read', 'clipboard-write', 'notifications']`)+ Browser permissions to grant.-- **browser_pid** (int | None, default: `None`)- Process ID of running Chrome to connect to.+- **storage_state** (str | Path | dict | None, default: `None`)+ Browser storage state (cookies, localStorage). Can be file path or dict.-<Note>When connecting to existing Chrome process, ensure it was started with --remote-debugging-port flag.</Note>+<Note>+ For web scraping tasks on sites that restrict automated access, we recommend+ using external browser or proxy providers for better reliability. See the [Connect to your Browser](real-browser) guide for detailed connection instructions.+</Note># Context Configuration@@ -135,7 +170,7 @@ The `BrowserProfile` class includes all context settings for the browser.```pythonfrom browser_use import BrowserSession, BrowserProfile-profile = BrowserProfile(+browser_profile = BrowserProfile(cookies_file="path/to/cookies.json",wait_for_network_idle_page_load_time=3.0,viewport={"width": 1280, "height": 1100},@@ -143,21 +178,24 @@ profile = BrowserProfile(user_agent='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.102 Safari/537.36',highlight_elements=True,viewport_expansion=500,- allowed_domains=['google.com', 'wikipedia.org'],+ allowed_domains=['*.google.com', 'http*://*.wikipedia.org'],)-session = BrowserSession(browser_profile=profile)+browser_session = BrowserSession(browser_profile=browser_profile)async def run_search():agent = Agent(- browser=session,task='Your task',- llm=llm)+ llm=llm,+ browser_session=browser_session,+ )```-## Configuration Options+## More BrowserProfile Parameters-### Page Load Settings+### Page Load and Timing Settings++These control how the browser waits for pages to load and timing between actions:- **minimum_wait_page_load_time** (float, default: `0.25`)Minimum time to wait before capturing page state for LLM input.@@ -177,7 +215,9 @@ async def run_search():- **default_navigation_timeout** (float | None, default: `None`)Default timeout for page navigation in milliseconds.-### Display Settings+### Display and Viewport Settings++Configure browser window size, viewport, and display properties:- **viewport** (dict | None, default: `None`)Viewport size with `width` and `height`. Example: `{"width": 1280, "height": 720}`@@ -197,15 +237,28 @@ async def run_search():- **screen** (dict | None, default: `None`)Screen size available to browser. Auto-detected if not specified.+### Localization and Appearance+- **locale** (str | None, default: `None`)Specify user locale, for example en-GB, de-DE, etc. Locale will affect the navigator.language value, Accept-Language request header value as well as number and date formatting rules.- **timezone_id** (str | None, default: `None`)Timezone identifier (e.g., 'America/New_York').-- **color_scheme** (str, default: `'light'`)+- **color_scheme** (ColorScheme, default: `'light'`)Preferred color scheme: `'light'`, `'dark'`, `'no-preference'`+- **contrast** (Contrast, default: `'no-preference'`)+ Contrast preference: `'no-preference'`, `'more'`, `'null'`++- **reduced_motion** (ReducedMotion, default: `'no-preference'`)+ Reduced motion preference: `'reduce'`, `'no-preference'`, `'null'`++- **forced_colors** (ForcedColors, default: `'none'`)+ Forced colors mode: `'active'`, `'none'`, `'null'`++### UI and DOM Settings+- **highlight_elements** (bool, default: `True`)Highlight interactive elements on the screen with colorful bounding boxes.@@ -215,33 +268,70 @@ async def run_search():- `0`: Only elements which are currently visible in the viewport will be included.- `500` (default): Elements in the viewport plus an additional 500 pixels in each direction will be included, providing a balance between context and token usage.-### Restrict URLs+- **include_dynamic_attributes** (bool, default: `True`)+ Include dynamic attributes in selectors for better element targeting.-- **allowed_domains** (list[str] | None, default: `None`)- List of allowed domains that the agent can access. If None, all domains are allowed.- Example: ['google.com', '*.wikipedia.org'] - Here the agent will only be able to access `google.com` exactly and `wikipedia.org` + `*.wikipedia.org`.-- Glob patterns are supported:- - `['example.com']` ✅ will match only `example.com` exactly, subdomains will not be allowed.- It's always the most secure to list all the domains you want to give the access to explicitly e.g.- `['google.com', 'www.google.com', 'myaccount.google.com', 'mail.google.com', 'docs.google.com']`- - `['*.example.com']` ⚠️ **CAUTION** this will match `example.com` and *all* subdomains.- Make sure *all* the subdomains are safe for the agent! `abc.example.com`, `def.example.com`, ..., `useruploads.example.com`, `admin.example.com`- - `['*google.com']` ❌ **DON'T DO THIS**, it will match any domains that end in `google.com`, *including `evilgoogle.com`*- - `['*.google.*']` ❌ **DON'T DO THIS**, it will match `google.com`, `google.co.uk`, `google.fr`, etc. *but also `www.google.evil.com`*+### Security and Network Settings-### Session Management+- **offline** (bool, default: `False`)+ Emulate network being offline.-- **keep_alive** (bool | None, default: `None`)- Keeps the browser context (tab/session) alive after an agent task has completed. This is useful for maintaining session state across multiple tasks.+- **http_credentials** (dict | None, default: `None`)+ Credentials for HTTP authentication.-- **storage_state** (str | Path | dict | None, default: `None`)- Browser storage state (cookies, localStorage). Can be file path or dict.+- **extra_http_headers** (dict[str, str], default: `{}`)+ Additional HTTP headers to be sent with every request.++- **ignore_https_errors** (bool, default: `False`)+ Whether to ignore HTTPS errors when sending network requests.++- **bypass_csp** (bool, default: `False`)+ Toggles bypassing Content-Security-Policy.++- **java_script_enabled** (bool, default: `True`)+ Whether or not to enable JavaScript in the context.++- **service_workers** (ServiceWorkers, default: `'allow'`)+ Whether to allow sites to register Service workers: `'allow'`, `'block'`++- **base_url** (str | None, default: `None`)+ Base URL to be used in `page.goto()` and similar operations.++- **strict_selectors** (bool, default: `False`)+ If true, selector passed to Playwright methods will throw if more than one element matches.++- **client_certificates** (list[ClientCertificate], default: `[]`)+ Client certificates to be used with requests.++### Mobile and Touch Emulation++- **is_mobile** (bool, default: `False`)+ Whether the meta viewport tag is taken into account and touch events are enabled.++- **has_touch** (bool, default: `False`)+ Specifies if viewport supports touch events.++- **geolocation** (dict | None, default: `None`)+ Geolocation coordinates. Example: `{"latitude": 59.95, "longitude": 30.31667}`++- **user_agent** (str | None, default: `None`)+ Specific user agent to use in this context.++### File Management- **cookies_file** (str | None, default: `None`)File to save cookies to.-### Debug and Recording+- **downloads_dir** (Path | str, default: `'~/.config/browseruse/downloads'`)+ Directory for downloads.++- **save_downloads_path** (str | None, default: `None`)+ Directory for saving downloads (alternative to downloads_dir).++- **profile_directory** (str, default: `'Default'`)+ Chrome profile directory name (e.g., 'Profile 1', 'Profile 2').++### Recording and Debugging- **save_recording_path** (str | None, default: `None`)Directory path for saving video recordings.@@ -258,56 +348,51 @@ async def run_search():- **record_har_path** (str | Path | None, default: `None`)Path to save HAR file with network activity.-- **slow_mo** (float, default: `0`)- Slow down operations by specified milliseconds.+- **record_har_content** (RecordHarContent, default: `'embed'`)+ How to persist HAR content: `'omit'`, `'embed'`, `'attach'`-- **devtools** (bool, default: `False`)- Auto-open DevTools panel (headful only).--## Complete BrowserProfile Parameters--For reference, here's the complete list of all available BrowserProfile parameters:--### Browser and Network-- `user_agent` - Custom user agent string-- `proxy` - Proxy settings-- `http_credentials` - HTTP authentication-- `extra_http_headers` - Additional HTTP headers-- `offline` - Emulate network offline-- `ignore_https_errors` - Ignore HTTPS errors-- `bypass_csp` - Bypass Content-Security-Policy-- `base_url` - Base URL for relative navigation--### JavaScript and Content-- `java_script_enabled` - Enable JavaScript-- `service_workers` - Service workers mode: 'allow', 'block'-- `accept_downloads` - Accept file downloads-- `permissions` - Granted permissions list-- `strict_selectors` - Strict selector mode-- `client_certificates` - Client certificates list--### Mobile and Touch-- `is_mobile` - Enable mobile emulation-- `has_touch` - Enable touch events-- `geolocation` - Geolocation coordinates--### Appearance-- `forced_colors` - Forced colors mode-- `reduced_motion` - Reduced motion preference-- `contrast` - Contrast preference--### Performance-- `deterministic_rendering` - Deterministic rendering-- `include_dynamic_attributes` - Include dynamic attributes in selectors-- `chromium_sandbox` - Enable Chromium sandboxing-- `ignore_default_args` - List of default args to ignore-- `handle_sigint` - Handle SIGINT signals-- `handle_sighup` - Handle SIGHUP signals-- `handle_sigterm` - Handle SIGTERM signals--### File Paths-- `downloads_dir` - Directory for downloads-- `save_downloads_path` - Alternative downloads directory-- `profile_directory` - Chrome profile directory name+- **record_har_mode** (RecordHarMode, default: `'full'`)+ HAR recording mode: `'full'`, `'minimal'`++- **record_har_omit_content** (bool, default: `False`)+ Whether to omit request content from the HAR.++- **record_har_url_filter** (str | Pattern | None, default: `None`)+ URL filter for HAR recording.++### Process Management++- **downloads_path** (str | Path | None, default: `None`)+ Directory to save downloads to (used by launch args).++- **traces_dir** (str | Path | None, default: `None`)+ Directory to save HAR trace files to.++- **handle_sighup** (bool, default: `True`)+ Whether playwright should swallow SIGHUP signals and kill the browser.++- **handle_sigint** (bool, default: `False`)+ Whether playwright should swallow SIGINT signals and kill the browser.++- **handle_sigterm** (bool, default: `False`)+ Whether playwright should swallow SIGTERM signals and kill the browser.++- **ignore_default_args** (list[str] | bool, default: `['--enable-automation', '--disable-extensions']`)+ List of default CLI args to stop playwright from applying.++## Summary++The parameters above represent all available configuration options for BrowserSession and BrowserProfile. The organization follows the Pydantic model structure:++- **BrowserSession** parameters (defined in `browser_use/browser/session.py`) handle connection and runtime state+- **BrowserProfile** parameters (defined in `browser_use/browser/profile.py`) handle all browser configuration, context settings, and behavior++`BrowserProfile` is a flat collection of config for multiple models:++- `BrowserConnectArgs` - Connection parameters+- `BrowserLaunchArgs` - Launch parameters+- `BrowserContextArgs` - Context parameters+- `BrowserNewContextArgs` - New context parameters+- `BrowserLaunchPersistentContextArgs` - Persistent context parametersFor more details on Playwright's browser context options, see the [official documentation](https://playwright.dev/python/docs/api/class-browsertype#browser-type-launch-persistent-context).