Collecting my attempts to improve at tech, art, and life

Playwright for Python

Tags: python testing browser-testing

There’s a Python interface to the very handy Playwright browser automation library. The 1.9.x releases feel more Pythonic. Naming conventions, stuff like that. Feels much less like just a wrapper.

Don’t forget to install browser drivers whenever you install or upgrade Playwright!

python -m playwright install

With pytest

The pytest-playwright plugin provides fixtures, marks, and extra pytest args for browser testing. So far the only fixture I’ve used is page, the stand-in for a default browser session. Pairs nicely with pytest-django’s live_server fixture.

Headless by default, but use pytest --headful if you want to watch the browser do its thing.


Since pytest-playwright is still in early days — 0.0.12 as of this bookmark date — dependency managers might not acknowledge new releases. Watch the repo and manually update your dependencies when you see a new release.

Added to vault 2024-01-15. Updated on 2024-02-01