This is a fork of Playwright for Python with browser control support. It connects to a running browser via a browser control server and Chrome extension, instead of launching a new browser instance.
- Python 3.9+
- Node.js 18+
- npm
- git
pip install git+https://github.com/jacobsparts/playwright-pythonThis automatically clones and builds the custom Playwright driver from source.
For development:
git clone https://github.com/jacobsparts/playwright-python
cd playwright-python
pip install -e .If you already have the Playwright Node.js repo checked out, skip the clone by setting:
PLAYWRIGHT_NODE_BUILD_DIR=/path/to/playwright pip install -e .Start the browser control server and load the extension in Chrome, then:
from playwright.sync_api import sync_playwright
p = sync_playwright().start()
browser = p.chromium.connect_to_browser_control("http://localhost:3001")
page = browser.contexts[0].pages[0]
page.goto("https://example.com")
print(page.title())
page.screenshot(path="example.png")You can also pass a session_id to reuse a specific browser session:
browser = p.chromium.connect_to_browser_control(
"http://localhost:3001",
session_id="my-session"
)