API reference¶
playwright_byob
¶
Bring your own browser to Playwright.
ChromeLaunchConfig
dataclass
¶
Resolved arguments for chromium.launch_persistent_context.
user_data_dir is passed as the first positional argument. options is
expanded as keyword arguments.
to_playwright_kwargs()
¶
Return a mutable copy of the keyword arguments for Playwright.
ChromeNotFoundError
¶
Bases: PlaywrightByobError
Raised when an explicitly requested Chrome executable cannot be found.
ChromeProfileNotFoundError
¶
Bases: PlaywrightByobError
Raised when the default Chrome user data directory cannot be found.
ConfigurationError
¶
Bases: PlaywrightByobError, ValueError
Raised when launch configuration is invalid.
PlaywrightByobError
¶
Bases: RuntimeError
Base exception for playwright-byob failures.
async_launch_chrome(playwright, *, browser_path='auto', user_data_dir='auto', profile_directory='auto', channel=DEFAULT_CHANNEL, headless=False, args=None, default_args=True, ignore_default_args=DEFAULT_IGNORE_DEFAULT_ARGS, no_viewport=True, **launch_options)
async
¶
Launch an async Playwright persistent context with installed Chrome.
build_chrome_launch_config(*, browser_path='auto', user_data_dir='auto', profile_directory='auto', channel=DEFAULT_CHANNEL, headless=False, args=None, default_args=True, ignore_default_args=DEFAULT_IGNORE_DEFAULT_ARGS, no_viewport=True, sys_platform=None, env=None, **launch_options)
¶
Build resolved launch parameters for Playwright's persistent context.
Defaults are intentionally tuned for using installed Google Chrome in headed mode with a persistent profile:
- use the installed Chrome executable when it can be found;
- otherwise ask Playwright to use the branded
chromechannel; - use the existing platform Chrome user data directory;
- select the
DefaultChrome profile directory; - run headed with Playwright's fixed viewport disabled;
- hide Playwright's
--enable-automationdefault argument.
Extra launch_options are passed directly to Playwright and can override
most defaults. Use args for additional Chrome flags, or set
default_args=False to opt out of this package's default Chrome flags.
chrome_executable_candidates(*, sys_platform=None, env=None)
¶
Return plausible Google Chrome executable paths for the current platform.
The function only builds candidates; it does not read profile data or launch
Chrome. The PLAYWRIGHT_BYOB_CHROME_PATH environment variable, when set,
is returned first.
chrome_user_data_dir_candidates(*, sys_platform=None, env=None)
¶
Return plausible Google Chrome user data directories.
These are profile roots such as .../Google/Chrome on macOS or
.../Google/Chrome/User Data on Windows. They may contain profile folders
named Default, Profile 1, and so on.
detect_chrome_executable(browser_path='auto', *, sys_platform=None, env=None)
¶
Return an existing Google Chrome executable, or None if not found.
Pass browser_path to check one explicit path. With the default
"auto", common platform locations and PLAYWRIGHT_BYOB_CHROME_PATH
are checked.
detect_chrome_user_data_dir(user_data_dir='auto', *, sys_platform=None, env=None)
¶
Return an existing Google Chrome user data directory, or None.