The
Browser instance also provides all Actor methods for direct browser control (page management, element interactions, etc.).Core Settings
cdp_url: CDP URL for connecting to existing browser instance (e.g.,"http://localhost:9222")
Navigation requests
await session.navigate_to(url, new_tab=False, *, wait_until="load", timeout_ms=None) uses the shared navigation request implementation. wait_until accepts commit, domcontentloaded, load, or networkidle. The last option waits for Chromium’s matching networkIdle lifecycle event. Document milestones do not establish application readiness.
timeout_ms must be positive and covers public-request queue time, target selection, the CDP command, readiness, and required observation work. A request with an explicit timeout receives an enclosing event timeout allowance before dispatch. If you dispatch NavigateToUrlEvent directly, an explicitly supplied event_timeout, including None, is preserved.
Without timeout_ms, the deadline uses the event timeout: 15 seconds by default, configurable with TIMEOUT_NavigateToUrlEvent. If that event timeout is disabled with None, navigation still has an internal 30-second default deadline.
The public method refuses overlapping requests with NavigationBusyError and propagates caller cancellation to the request owner. It never retries a navigation automatically. Raw event dispatch keeps the event bus’s queue semantics; cancelling a raw event waiter alone does not cancel its handler.
Read session.lifecycle_snapshot()["navigation"] for the active or last operation. A terminal phase is succeeded, download, failed, timed_out, or cancelled. A download phase acknowledges a handoff, not a completed file or loaded document. NavigationFinishedEvent reports the correlated outcome; legacy NavigationCompleteEvent remains an observation also used for focus and PDF discovery. Terminal status delivery is not durable across event-bus shutdown.
Requested URLs are checked before navigation. While a request owns its captured target, policy also checks observed top-level commits independently of acknowledgment and document readiness. A forbidden committed document triggers conditional, document-bound containment to about:blank, even when a resource stalls. This is not a network filter or a continuous watcher after request retirement.
navigation.containment reports cleanup separately from the primary navigation outcome. Timeout or cancellation does not discard a security action that might already have been sent. Preparation has a one-second deadline. After the action acknowledges initiation, verification uses a separate one-second polling deadline and one-second bounds on each CDP frame read. These are not a total cleanup timeout. An already-sent action can outlive those waits and remains tracked. contained means verification observed about:blank.
If sent authority remains unconfirmed, the runtime stays failed and refuses replacement. Inspect status before retrying. To recover, close the actual browser and create a new BrowserSession. kill() can verify the exit of a managed local browser. A lost remote connection does not prove that the remote browser exited. If delayed cleanup is later verified, only its own unchanged lifecycle failure can move to degraded, not ready; explicit recovery is then available.
Display & Appearance
headless(default:True): Run browser without UI.Noneresolves toTrue; setFalseto show the window.auto_split_screen(default:True): In headful mode, position the browser on the right half of the screen unless an explicit window size or position is set.window_size: Browser window size for headful mode. Use dict{'width': 1920, 'height': 1080}orViewportSizeobjectwindow_position(default:{'width': 0, 'height': 0}): Window position from top-left corner in pixelsviewport: Content area size, same format aswindow_size. Use{'width': 1280, 'height': 720}orViewportSizeobjectno_viewport(default:None): Disable viewport emulation, content fits to window sizedevice_scale_factor: Device scale factor (DPI). Set to2.0or3.0for high-resolution screenshots
Browser Behavior
keep_alive(default:None): Keep browser running after agent completesallowed_domains: Restrict navigation to specific domains. Domain pattern formats:'example.com'- Matches onlyhttps://example.com/*'*.example.com'- Matcheshttps://example.com/*and any subdomainhttps://*.example.com/*'http*://example.com'- Matches bothhttp://andhttps://protocols'chrome-extension://*'- Matches any Chrome extension URL- Security: Wildcards in TLD (e.g.,
example.*) are not allowed for security - Use list like
['*.google.com', 'https://example.com', 'chrome-extension://*'] - Performance: Lists with 100+ domains are automatically optimized to sets for O(1) lookup. Pattern matching is disabled for optimized lists. Both
www.example.comandexample.comvariants are checked automatically.
prohibited_domains: Block navigation to specific domains. Uses same pattern formats asallowed_domains. When bothallowed_domainsandprohibited_domainsare set,allowed_domainstakes precedence. Examples:['pornhub.com', '*.gambling-site.net']- Block specific sites and all subdomains['https://explicit-content.org']- Block specific protocol/domain combination- Performance: Lists with 100+ domains are automatically optimized to sets for O(1) lookup (same as
allowed_domains)
enable_default_extensions(default:True): Load automation extensions (uBlock Origin, cookie handlers, ClearURLs)cross_origin_iframes(default:True): Enable cross-origin iframe support (OOPIF). Set toFalseto process only same-origin frames.is_local(default:False): Whether this is a local browser instance.BrowserSessionsets it toTruewhen nocdp_urlis supplied, or whenexecutable_pathis set. Set it explicitly for remote browsers. This affects download behavior.
User Data & Profiles
user_data_dir(default: auto-generated temp): Directory for browser profile data.Nonecreates a throwaway temporary profile directory withtempfile.mkdtemp, not Chrome incognito mode.profile_directory(default:'Default'): Chrome profile subdirectory name ('Profile 1','Work Profile', etc.)storage_state: Browser storage state (cookies, localStorage). Can be file path string or dict object
Network & Security
-
proxy: Proxy configuration usingProxySettings(server='http://host:8080', bypass='localhost,127.0.0.1', username='user', password='pass') -
permissions(default:['clipboardReadWrite', 'notifications']): Browser permissions to grant. Use list like['camera', 'microphone', 'geolocation'] -
headers: Additional HTTP headers for connect requests (remote browsers only) -
block_ip_addresses(default:False): Block navigation to URLs whose host is a literal IPv4 or IPv6 address. Hostnames such aslocalhostare not resolved, so this flag does not block them by itself.
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'
- macOS:
channel: Browser channel ('chromium','chrome','chrome-beta','msedge', etc.)args: Additional command-line arguments for the browser. Use list format:['--disable-gpu', '--custom-flag=value', '--another-flag']env: Environment variables for browser process. Use dict like{'DISPLAY': ':0', 'LANG': 'en_US.UTF-8', 'CUSTOM_VAR': 'test'}chromium_sandbox(default:Trueexcept in Docker): Enable Chromium sandboxing for securitydevtools(default:False): Open DevTools panel automatically (requiresheadless=False)ignore_default_args: List of default args to disable, orTrueto disable all. Use list like['--enable-automation', '--disable-extensions']
Timing & Performance
minimum_wait_page_load_time(default:0.25): Minimum time to wait before capturing page state in secondswait_for_network_idle_page_load_time(default:0.5): Time to wait for network activity to cease in secondswait_between_actions(default:0.1): Time to wait between agent actions in seconds
AI Integration
highlight_elements(default:True): Highlight interactive elements for AI visionpaint_order_filtering(default:True): Enable paint order filtering to optimize DOM tree by removing elements hidden behind others. Slightly experimental
Downloads & Files
accept_downloads(default:True): Automatically accept all downloadsdownloads_path(default: unique/tmp/openbrowser-downloads-<id>): Directory for downloaded files. Use a string like'./downloads'or aPathobject.auto_download_pdfs(default:True): 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 aswindow_size
Recording & Debugging
record_video_dir: Directory to save video recordings as.mp4filesrecord_video_size(default:None): The frame size (width, height) of the video recording.Noneuses the viewport size.record_video_framerate(default:30): The framerate to use for the video recording.record_har_path: Path to save network trace files as.harformattraces_dir: Directory to save complete trace files for debuggingrecord_har_content(default:'embed'): HAR content mode ('omit','embed','attach')record_har_mode(default:'full'): HAR recording mode ('full','minimal')
Advanced Options
disable_security(default:False): ⚠️ NOT RECOMMENDED - Disables all browser security featuresdeterministic_rendering(default:False): ⚠️ NOT RECOMMENDED - Forces consistent rendering but reduces performance
Using BrowserProfile
BrowserProfile is a first-class configuration object. Pass it to BrowserSession when you want to reuse one configuration across sessions. Direct keyword arguments to BrowserSession are the convenience path.
Browser vs BrowserSession
Browser is an alias for BrowserSession - they are exactly the same class:
Use Browser for cleaner, more intuitive code.