StagehandBrowserPlugin
Hierarchy
- BrowserPlugin
- StagehandBrowserPlugin
Index
Methods
__aenter__
Enter the context manager and initialize the browser plugin.
Returns BrowserPlugin
__aexit__
Exit the context manager and close the browser plugin.
Parameters
exc_type: type[BaseException] | None
exc_value: BaseException | None
exc_traceback: TracebackType | None
Returns None
__init__
Initialize a new instance.
Parameters
optionalkeyword-onlyuser_data_dir: (str | Path) | None = None
Path to a user data directory, which stores browser session data like cookies and local storage.
optionalkeyword-onlystagehand_options: StagehandOptions | None = None
Stagehand-specific configuration (model, API key, env, etc.).
optionalkeyword-onlybrowser_launch_options: dict[str, Any] | None = None
Keyword arguments passed to Stagehand's
BrowserLaunchOptionson session start. Supported keys are a subset of Playwright'sbrowser_type.launchoptions. These take priority overbrowser_new_context_optionsfor shared keys.optionalkeyword-onlybrowser_new_context_options: dict[str, Any] | None = None
Additional options merged with
browser_launch_optionsat lower priority. Subject to the sameBrowserLaunchOptionsconstraints.optionalkeyword-onlymax_open_pages_per_browser: int = 20
The maximum number of pages that can be open in a single browser instance. Once reached, a new browser instance will be launched.
Returns None
new_browser
Create a new browser instance.
Returns BrowserController
A new browser instance wrapped in a controller.
Properties
active
Indicate whether the context is active.
AUTOMATION_LIBRARY
The name of the automation library that the plugin is managing.
browser_launch_options
Return the options passed to Stagehand's BrowserLaunchOptions on session start.
These are a subset of Playwright's browser_type.launch options — only keys recognised by Stagehand's
BrowserLaunchOptions take effect.
browser_new_context_options
Return the browser context options passed to Stagehand's BrowserLaunchOptions.
Stagehand creates the browser and its context together in a single sessions.start() call, so context-level
options such as viewport and locale are part of BrowserLaunchOptions and share the same dictionary as
browser_launch_options. Pre-navigation hooks that modify these options before the first page will take effect,
because session creation is deferred until the first new_page call.
browser_type
Return the browser type name.
max_open_pages_per_browser
Return the maximum number of pages that can be opened in a single browser.
stagehand_options
Return the Stagehand-specific configuration options.
A plugin for managing Stagehand AI-powered browser automation.
It acts as a factory for creating
StagehandBrowserControllerinstances and manages the lifecycle of the sharedAsyncStagehandREST client and the Playwright context. Depending on the configured environment, the browser runs locally via a bundled Chromium binary (env='LOCAL') or in the Browserbase cloud (env='BROWSERBASE'). Playwright connects to the running browser via CDP, so only Chromium is supported.Not all Playwright browser and context options are supported — only those accepted by Stagehand's
BrowserLaunchOptions. Because Stagehand creates the browser and its context together in a singlesessions.start()call, bothbrowser_launch_optionsandbrowser_new_context_optionsare merged into one set of options applied at session start.