Browser Settings
Launch or connect to an existing browser and configure it to your needs.
Browser Use uses playwright (or patchright) to manage its connection with a real browser.
To launch or connect to a browser, pass any playwright / browser-use configuration arguments you want to BrowserSession(...)
:
The new BrowserSession
& BrowserProfile
accept all the same arguments that Playwright’s launch_persistent_context(...)
takes, giving you full control over browser settings at launch. (see below for the full list)
BrowserSession
BrowserSession(**params)
is Browser Use’s object that tracks a connection to a running browser. It sets up:- the
playwright
,browser
,browser_context
, andpage
objects and tracks which tabs the agent/human are focused on - methods to interact with the browser window, apply config needed by the Agent, and run the
DOMService
for element detection - it can take a
browser_profile=BrowserProfile(...)
template containing some config defaults, and**kwargs
session-specific config overrides
- the
Browser Connection Parameters
Provide any one of these options to connect to an existing browser. These options are session-specific and cannot be stored in a BrowserProfile(...)
template.
wss_url
WSS URL of the playwright-protocol browser server to connect to. See here for WSS connection instructions.
cdp_url
CDP URL of the browser to connect to (e.g. http://localhost:9222
). See here for CDP connection instructions.
browser_pid
PID of a running chromium-based browser process to connect to on localhost. See here for connection via pid instructions.
For web scraping tasks on sites that restrict automated access, we recommend using our cloud or an external browser provider for better reliability. See the Connect to your Browser guide for detailed connection instructions.
Session-Specific Parameters
browser_profile
Optional BrowserProfile
template containing default config to use for the BrowserSession
. (see below for more info)
playwright
Optional playwright or patchright API client object to use, the
result of (await async_playwright().start())
or (await async_patchright().start())
. See here for more detailed usage instructions.
browser
Playwright Browser object to use (optional). See here for more detailed usage instructions.
browser_context
Playwright BrowserContext object to use (optional). See here for more detailed usage instructions.
page
aka agent_current_page
Foreground Page that the agent is focused on, can also be passed as page=...
as a shortcut. See here for more detailed usage instructions.
human_current_page
Foreground Page that the human is focused on to start, usually not necessary to set manually.
initialized
Mark BrowserSession as already initialized, skips launch/connection (not recommended)
**kwargs
BrowserSession
can also accept all of the parameters below.
(the parameters above this point are specific to BrowserSession
and cannot be stored in a BrowserProfile
template)
Extra **kwargs
passed to BrowserSession(...)
act as session-specific overrides to the BrowserProfile(...)
template.
BrowserProfile
A BrowserProfile
is a static config template for a BrowserSession()
.
It can validate and hold all the standard playwright arguments and the extra config arguments Browser Use provides.
It allows you do do things like start multiple browser processes with some shared config:
Browser-Use Parameters
These parameters control Browser Use-specific features, and are outside the standard playwright set. They can be passed to BrowserSession(...)
and/or stored in a BrowserProfile
template.
keep_alive
Keeps the browser alive after the agent has finished running. Useful for running multiple tasks with the same browser instance. If this is left as None
and the Agent launched its own browser, the default is to close the browser after the agent completes. If the agent connected to an existing browser then it will leave it open.
allowed_domains
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 onlyhttps://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.['https://google.com', 'http*://www.google.com', 'https://myaccount.google.com', 'https://mail.google.com', 'https://docs.google.com']
['*.example.com']
⚠️ CAUTION this will matchhttps://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
disable_security
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.
deterministic_rendering
Enable deterministic rendering flags for consistent screenshots.
highlight_elements
Highlight interactive elements on the screen with colorful bounding boxes.
viewport_expansion
Viewport expansion in pixels. With this you can control how much of the page is included in the context of the LLM:
-1
: All elements from the entire page will be included, regardless of visibility (highest token usage but most complete).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.
include_dynamic_attributes
Include dynamic attributes in selectors for better element targeting.
minimum_wait_page_load_time
Minimum time to wait before capturing page state for LLM input.
wait_for_network_idle_page_load_time
Time to wait for network activity to cease. Increase to 3-5s for slower websites. This tracks essential content loading, not dynamic elements like videos.
maximum_wait_page_load_time
Maximum time to wait for page load before proceeding.
wait_between_actions
Time to wait between agent actions.
cookies_file
JSON file path to save cookies to.
This option is DEPRECATED. Use storage_state
instead, it’s the standard playwright format and also supports localStorage
!
Transfer any cookies from your existing cookies_file
to the new JSON format:
cookies_file.json
: [{cookie}, {cookie}, {cookie}]
⬇️
storage_state.json
: {"cookies": [{cookie}, {cookie}, {cookie}], "origins": {... optional localstorage state ...}}
Or run playwright open https://example.com/ --save-storage=storage_state.json
and log into any sites you need.
downloads_dir
Directory to save browser downloads in.
(previously called save_downloads_path
in some places)
profile_directory
Chrome profile subdirectory name inside of your user_data_dir
(e.g. Default
, Profile 1
, Work
, etc.).
window_position
Window position from top-left corner.
save_recording_path
Directory path for saving video recordings.
trace_path
Directory path for saving Agent trace files. Files are automatically named as {trace_path}/{context_id}.zip
.
Playwright Launch Options
All the parameters below are standard playwright parameters and can be passed to both BrowserSession
and BrowserProfile
.
They are defined in browser_use/browser/profile.py
. See here for the official Playwright documentation for all of these options.
headless
Runs the browser without a visible UI. If None, auto-detects based on display availability.
channel
Browser channel: 'chromium'
, 'chrome'
, 'chrome-beta'
, 'chrome-dev'
, 'chrome-canary'
, 'msedge'
, 'msedge-beta'
, 'msedge-dev'
, 'msedge-canary'
Don’t worry, other chromium-based browsers not in this list (e.g. brave
) are still supported if you provide your own executable_path
.
executable_path
Path to browser executable for custom installations.
user_data_dir
Directory for browser profile data. Set to None
to use an ephemeral temporary profile (aka incognito mode).
Multiple running browsers cannot share a single user_data_dir
at the same time. You must set it to None
or
provide a unique user_data_dir
per-session if you plan to run multiple browsers.
The browser version run must always be equal to or greater than the version used to create the user_data_dir
.
If you see errors like Failed to parse Extensions
or similar and failures when launching, you’re attempting to run an older browser with an incompatible user_data_dir
that’s already been migrated to a newer schema version.
args
Additional command-line arguments to pass to the browser. See here for the full list of available chrome launch options.
ignore_default_args
List of default CLI args to stop playwright from including when launching chrome. Set it to True
to disable all default options (not recommended).
env
Extra environment variables to set when launching browser. e.g. {'DISPLAY': '1'}
to use a specific X11 display.
chromium_sandbox
Whether to enable Chromium sandboxing (recommended for security). Should always be False
when running inside Docker
because Docker provides its own sandboxing can conflict with Chrome’s.
devtools
Whether to open DevTools panel automatically (only works when headless=False
).
slow_mo
Slow down actions by this many milliseconds.
timeout
Default timeout in milliseconds for connecting to a remote browser.
accept_downloads
Whether to automatically accept all downloads.
proxy
Proxy settings. Example: {"server": "http://proxy.com:8080", "username": "user", "password": "pass"}
.
permissions
Browser permissions to grant. See here for the full list of available permission.
storage_state
Browser storage state (cookies, localStorage). Can be file path or dict. See here for the Playwright storage_state
documentation on how to use it.
This option is only applied when launching a new browser using the default builtin playwright chromium and user_data_dir=None
is set.
Playwright Timing Settings
These control how the browser waits for CDP API calls to complete and pages to load.
default_timeout
Default timeout for Playwright operations in milliseconds.
default_navigation_timeout
Default timeout for page navigation in milliseconds.
Playwright Viewport Options
Configure browser window size, viewport, and display properties:
user_agent
Specific user agent to use in this context.
is_mobile
Whether the meta viewport tag is taken into account and touch events are enabled.
has_touch
Specifies if viewport supports touch events.
geolocation
Geolocation coordinates. Example: {"latitude": 59.95, "longitude": 30.31667}
locale
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
Timezone identifier (e.g., ‘America/New_York’).
window_size
Browser window size for headful mode. Example: {"width": 1920, "height": 1080}
viewport
Viewport size with width
and height
. Example: {"width": 1280, "height": 720}
no_viewport
Disable fixed viewport. Content will resize with window.
Tip: don’t use this parameter, it’s a playwright standard parameter but it’s redundant and only serves to override the viewport
setting above.
A viewport is always used in headless mode regardless of this setting, and is never used in headful mode unless you pass viewport={width, height}
explicitly.
device_scale_factor
Device scale factor (DPI). Useful for high-resolution screenshots (set it to 2).
screen
Screen size available to browser. Auto-detected if not specified.
color_scheme
Preferred color scheme: 'light'
, 'dark'
, 'no-preference'
contrast
Contrast preference: 'no-preference'
, 'more'
, 'null'
reduced_motion
Reduced motion preference: 'reduce'
, 'no-preference'
, 'null'
forced_colors
Forced colors mode: 'active'
, 'none'
, 'null'
**playwright.devices[...]
Playwright provides launch & context arg presets to emulate common device fingerprints.
Because BrowserSession
and BrowserProfile
take all the standard playwright args, we are able to support these device presets as well.
Playwright Security Options
See
allowed_domains
above too!
offline
Emulate network being offline.
http_credentials
Credentials for HTTP authentication.
extra_http_headers
Additional HTTP headers to be sent with every request.
ignore_https_errors
Whether to ignore HTTPS errors when sending network requests.
bypass_csp
Toggles bypassing Content-Security-Policy.
java_script_enabled
Whether or not to enable JavaScript in the context.
service_workers
Whether to allow sites to register Service workers: 'allow'
, 'block'
base_url
Base URL to be used in page.goto()
and similar operations.
strict_selectors
If true, selector passed to Playwright methods will throw if more than one element matches.
client_certificates
Client certificates to be used with requests.
Playwright Recording Options
Note: Browser Use also provides some of our own recording-related options not listed below (see above).
record_video_dir
Directory to save video recordings. Playwright Docs: record_video_dir
record_video_size
Video size. Example: {"width": 1280, "height": 720}
record_har_path
Path to save HAR file with network activity.
record_har_content
How to persist HAR content: 'omit'
, 'embed'
, 'attach'
record_har_mode
HAR recording mode: 'full'
, 'minimal'
record_har_omit_content
Whether to omit request content from the HAR.
record_har_url_filter
URL filter for HAR recording.
downloads_path
Directory to save downloads to (used by launch args).
traces_dir
Directory to save HAR trace files to.
handle_sighup
Whether playwright should swallow SIGHUP signals and kill the browser.
handle_sigint
Whether playwright should swallow SIGINT signals and kill the browser.
handle_sigterm
Whether playwright should swallow SIGTERM signals and kill the browser.
Full Example
Summary
- BrowserSession (defined in
browser_use/browser/session.py
) handles the live browser connection and runtime state - BrowserProfile (defined in
browser_use/browser/profile.py
) is a template that can store default config parameters for aBrowserSession(...)
Configuration parameters defined in both scopes consumed by these calls depending on whether we’re connecting/launching:
BrowserConnectArgs
- args forplaywright.BrowserType.connect_over_cdp(...)
BrowserLaunchArgs
- args forplaywright.BrowserType.launch(...)
BrowserNewContextArgs
- args forplaywright.BrowserType.new_context(...)
BrowserLaunchPersistentContextArgs
- args forplaywright.BrowserType.launch_persistent_context(...)
- Browser Use’s own internal methods
For more details on Playwright’s browser context options, see the official documentation.