Skip to content

jacobsparts/playwright-python

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1,009 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Playwright for Python — Browser Control Fork

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.

Prerequisites

  • Python 3.9+
  • Node.js 18+
  • npm
  • git

Install

pip install git+https://github.com/jacobsparts/playwright-python

This 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 .

Usage

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"
)

About

Python version of the Playwright testing and automation library.

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • Python 99.1%
  • Other 0.9%