Browser class (alias for BrowserSession) configures how the browser launches and operates.
The
Browser instance also provides all Actor methods for direct browser control.Core Settings
cdp_url
Chrome DevTools Protocol URL for connecting to an existing browser instance.Example:
"http://localhost:9222"Use this to connect to remote browsers or existing browser sessions.Display & Appearance
headless
Run browser without visible UI.
True- Headless mode (no window)False- Headed mode (show browser window)None- Auto-detect based on display availability
window_size
Browser window size for headed mode.Example:
{'width': 1920, 'height': 1080}window_position
Window position from top-left corner in pixels.Example:
{'width': 100, 'height': 50}viewport
Content area size (rendering area inside the window).Example:
{'width': 1280, 'height': 720}Same format as window_size.no_viewport
Disable viewport emulation - content fits to window size.
device_scale_factor
Device scale factor (DPI multiplier).Set to
2.0 or 3.0 for high-resolution screenshots.Browser Behavior
keep_alive
Keep browser running after agent completes.Useful for debugging or manual inspection.
allowed_domains
Restrict navigation to specific domains.Pattern formats:
'example.com'- Matches onlyhttps://example.com/*'*.example.com'- Matcheshttps://example.com/*and subdomains'http*://example.com'- Matches both http and https'chrome-extension://*'- Matches Chrome extension URLs
example.*) are not allowedPerformance: Lists with 100+ domains are automatically optimized for O(1) lookupExample: ['*.google.com', 'https://example.com', 'chrome-extension://*']prohibited_domains
Block navigation to specific domains. Uses same pattern formats as
allowed_domains.When both allowed_domains and prohibited_domains are set, allowed_domains takes precedence.Example: ['pornhub.com', '*.gambling-site.net']enable_default_extensions
Load automation extensions:
- uBlock Origin (ad blocker)
- Cookie handlers
- ClearURLs (tracker removal)
cross_origin_iframes
Enable cross-origin iframe support.Note: May increase complexity
is_local
Whether this is a local browser instance.Set to
False for remote browsers. Automatically set to True if executable_path is provided.This affects download behavior and file handling.User Data & Profiles
user_data_dir
Directory for browser profile data (cookies, history, extensions).Use
None for incognito mode (no persistent data).profile_directory
Chrome profile subdirectory name.Examples:
'Profile 1', 'Work Profile'storage_state
Browser storage state (cookies, localStorage).Can be a file path (string) or a dict object.
Network & Security
proxy
Proxy configuration.Example:
permissions
Browser permissions to grant automatically.Example:
['camera', 'microphone', 'geolocation']headers
Additional HTTP headers for connect requests.Remote browsers only
Browser Launch
executable_path
Path to browser executable for custom installations.Platform examples:
- macOS:
'/Applications/Google Chrome.app/Contents/MacOS/Google Chrome' - Windows:
'C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe' - Linux:
'/usr/bin/google-chrome'
channel
Browser channel to use.Options:
'chromium', 'chrome', 'chrome-beta', 'msedge'args
Additional command-line arguments for the browser.Example:
['--disable-gpu', '--custom-flag=value', '--another-flag']env
Environment variables for browser process.Example:
{'DISPLAY': ':0', 'LANG': 'en_US.UTF-8', 'CUSTOM_VAR': 'test'}chromium_sandbox
Enable Chromium sandboxing for security.Automatically disabled in Docker environments.
devtools
Open DevTools panel automatically.Requires:
headless=Falseignore_default_args
List of default args to disable, or
True to disable all.Example: ['--enable-automation', '--disable-extensions']Timing & Performance
minimum_wait_page_load_time
Minimum time to wait before capturing page state (seconds).
wait_for_network_idle_page_load_time
Time to wait for network activity to cease (seconds).
wait_between_actions
Time to wait between agent actions (seconds).
AI Integration
highlight_elements
Highlight interactive elements for AI vision.Adds visual markers to clickable elements in screenshots.
paint_order_filtering
Enable paint order filtering to optimize DOM tree.Removes elements hidden behind others. Slightly experimental.
Downloads & Files
accept_downloads
Automatically accept all downloads.
downloads_path
Directory for downloaded files.Example:
'./downloads'auto_download_pdfs
Automatically download PDFs instead of viewing in browser.
Device Emulation
user_agent
Custom user agent string.Example:
'Mozilla/5.0 (iPhone; CPU iPhone OS 14_0 like Mac OS X)'screen
Screen size information. Same format as
window_size.Recording & Debugging
record_video_dir
Directory to save video recordings as
.mp4 files.record_video_size
Frame size (width, height) for video recording.
record_video_framerate
Framerate for video recording.
record_har_path
Path to save network trace files as
.har format.traces_dir
Directory to save complete trace files for debugging.
record_har_content
HAR content mode.
record_har_mode
HAR recording mode.
Advanced Options
disable_security
⚠️ NOT RECOMMENDED - Disables all browser security features.Only use for testing in controlled environments.
deterministic_rendering
⚠️ NOT RECOMMENDED - Forces consistent rendering but reduces performance.
Example
Related Configuration
- Agent Settings - Configure agent behavior
- Sandbox Settings - Configure cloud execution