playwright-byob
Bring your own browser to Playwright.
playwright-byob is a tiny Python helper for launching Playwright against the real Google Chrome installation already present on a machine. It keeps the API close to Playwright, but chooses practical defaults for headed, persistent Chrome automation.
Installation
pip install playwright-byob
With uv:
uv add playwright-byob
Quick start
from playwright.sync_api import sync_playwright
from playwright_byob import launch_chrome
with sync_playwright() as p:
context = launch_chrome(p)
page = context.new_page()
page.goto("https://example.com")
print(page.title())
context.close()
The default launch uses installed Chrome when detected, falls back to
Playwright's channel="chrome", opens headed, uses the platform Chrome user
data directory, selects the Default profile, disables Playwright's fixed
viewport, and removes the --enable-automation default argument.
Customize the browser or profile
from playwright.sync_api import sync_playwright
from playwright_byob import launch_chrome
with sync_playwright() as p:
context = launch_chrome(
p,
browser_path="/Applications/Google Chrome.app/Contents/MacOS/Google Chrome",
user_data_dir="~/Library/Application Support/Google/Chrome",
profile_directory="Profile 1",
args=["--window-size=1440,1000"],
timeout=30_000,
)
You can also use environment variables:
PLAYWRIGHT_BYOB_CHROME_PATHPLAYWRIGHT_BYOB_USER_DATA_DIRPLAYWRIGHT_BYOB_PROFILE_DIRECTORY
Recommended profile patterns
Using the installed Chrome binary and using your daily Chrome profile are separate choices. In practice, the most reliable paths are:
- Installed Chrome with a temporary profile.
Use
tempfile.TemporaryDirectory()asuser_data_dirandprofile_directory=None, then log in during the run. This avoids downloading Playwright Chromium without touching a personal Chrome profile. - Installed Chrome with a dedicated automation profile.
Create a separate Chrome profile for automation and point
user_data_dirandprofile_directoryat it. Keep it out of day-to-day browsing. - Installed Chrome with a real user profile. This is convenient for local one-off scripts, but it can expose sensitive state, conflict with a profile already open in Chrome, or trigger account verification prompts.
Playwright's authentication guide also describes saving authenticated browser
state to JSON files with context.storage_state(path=...) and keeping those
files out of source control. Because playwright-byob launches persistent
contexts, it cannot pass storage_state directly at launch time, but exporting
state after login is still useful when a workflow later uses standard
Playwright contexts.
Privacy note
A real Chrome profile or exported storage-state JSON file can contain cookies, local storage, saved sessions, and other sensitive state, so use these intentionally. Tests in this project never read or launch a real user profile. They use temporary directories and fake Playwright objects.
The local integration test is macOS-only and skipped in CI. It launches the installed Chrome executable with an isolated temporary user data directory, then verifies cookie and local storage persistence across two browser sessions.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file playwright_byob-0.1.2.tar.gz.
File metadata
- Download URL: playwright_byob-0.1.2.tar.gz
- Upload date:
- Size: 12.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.28 {"installer":{"name":"uv","version":"0.11.28","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5507952126d2971241557e2aa9fb39b4490b1dee27aaf52f166d0c4a4bf53fe6
|
|
| MD5 |
82129848295257135a9628df53e76b5e
|
|
| BLAKE2b-256 |
a070aa58148cacff01140880bd863d06f8722801422af9df1d7068294c04ed55
|
File details
Details for the file playwright_byob-0.1.2-py3-none-any.whl.
File metadata
- Download URL: playwright_byob-0.1.2-py3-none-any.whl
- Upload date:
- Size: 8.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.28 {"installer":{"name":"uv","version":"0.11.28","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5706429e4c8f158ed7edb97eaaecfc6814521089333f8d32fa31654f7db978ab
|
|
| MD5 |
f48ca6ca844e81f14aab73127425404b
|
|
| BLAKE2b-256 |
20698629c4218618963566e9c822ef1292dda9126ecab91b5aaefa5bdda84bf0
|