pytest-playwright
A pytest wrapper with fixtures for Playwright to automate web browsers
What it is and what it does
pytest-playwright is a pytest plugin that wraps the Playwright browser automation library, exposing browser primitives as pytest fixtures so you can write end-to-end tests directly in your test functions. Instead of manually instantiating and managing browser contexts, you declare a `page` fixture (or `browser`, `context` fixtures) in your test signature and pytest-playwright handles the setup and teardown. It supports all modern browsers—Chromium, WebKit, and Firefox—and can run tests in headless or headed mode.
The plugin is maintained by Microsoft (Playwright's creator) and sits at the intersection of pytest's test discovery and fixture system with Playwright's cross-browser automation API. It's designed for teams writing web application tests that need to verify behavior across multiple browsers without writing boilerplate context management code. The package has no known vulnerabilities and is actively developed, with a recent release and steady repository maintenance.
Use it for:
- Write end-to-end tests for web applications that verify user workflows across Chromium, Firefox, and WebKit without manual browser setup.
- Run headless browser tests in CI/CD pipelines to validate web app functionality on every commit.
- Test responsive design and cross-browser compatibility by parameterizing tests to run against multiple browser contexts.
- Automate visual regression testing or screenshot capture as part of pytest test suites.
- Verify form submissions, navigation, and DOM interactions in web apps using Playwright's page API within pytest test functions.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
A pytest plugin that integrates Playwright browser automation into pytest test functions via built-in fixtures, enabling end-to-end testing across Chromium, WebKit, and Firefox in headless or headed mode.
Yes. This is a well-maintained, actively developed plugin from Microsoft with no known vulnerabilities, low install friction, and a permissive license. It fills a clear need for teams using pytest who want to write end-to-end browser tests without boilerplate. The only gotcha is that Playwright requires browser binaries to be installed separately, but that is a one-time setup step and is well-documented.
Install
pytest-playwright on PyPI
pip
pip install pytest-playwrightuv
uv add pytest-playwrightpoetry
poetry add pytest-playwrightInstalling pytest-playwright
Before you install
Low friction install with a pure-Python wheel. Actively maintained with a recent release (4 days old) and steady repository activity. Requires Python 3.10 or later and depends on playwright, pytest, pytest-base-url, and python-slugify—all standard testing and utility packages.
License in practice
Licensed under Apache License 2.0 (permissive). You can use, modify, and distribute the package freely in commercial and private projects, provided you include a copy of the license and note any changes you make.
Quickstart
pip install pytest-playwright
# In a test file:
import pytest
def test_example(page):
page.goto("https://example.com")
assert page.title() == "Example Domain"
Requires Python 3.10 or later. Playwright also requires browser binaries; use `playwright install` after installing the package to download them.
Verify before relying
- Whether pytest-base-url and python-slugify are required at runtime or only for specific test scenarios.
- Whether the plugin automatically handles browser binary installation or if manual setup is needed in CI/CD environments.
Package facts
| License | Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for… (full text in the JSON record) (permissive) |
| Python support | supports the current Python release (>=3.10) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 4 — playwright, pytest, pytest-base-url, python-slugify |
| Maintenance | actively maintained — 4 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 9,625,460/month — #1,516 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: pytest_playwright-0.9.0-py3-none-any.whl
Tags
More Testing packages
Pluggy provides a plugin system that lets you…
permissive · top 100 on PyPI
pytestpytest is a testing framework that lets you…
permissive · top 100 on PyPI
virtualenvvirtualenv creates isolated Python environments…
permissive · top 100 on PyPI
coverageCoverage.py measures which lines of Python code…
permissive · top 1,000 on PyPI
pytest-asynciopytest-asyncio is a pytest plugin that enables…
permissive · top 1,000 on PyPI
pytest-json-ctrfA pytest plugin that generates test reports in…
permissive · top 1,000 on PyPI
pytest-playwright-asyncioA pytest plugin that integrates Playwright…
permissive · top 15,000 on PyPI
wptserveA Python web server built for testing web…
permissive · top 15,000 on PyPI
playwrightAutomate Chromium, Firefox, and WebKit browsers…
permissive · top 1,000 on PyPI
camoufoxPython wrapper around Playwright that…
permissive · top 5,000 on PyPI
scrapy-playwrightIntegrates Playwright browser automation into…
permissive · top 5,000 on PyPI
pyppeteerAutomates headless Chrome/Chromium browser…
permissive · top 5,000 on PyPI
robotframework-browserBrowser automation library for Robot Framework…
permissive · top 5,000 on PyPI
testmuai-playwright-bindingsRuns exported browser automation tests locally…
permissive · top 15,000 on PyPI
robocorp-browserA wrapper around Playwright that automates…
permissive · top 15,000 on PyPI
eyes-commonBase SDK package for Applitools Eyes that…
unclear · top 15,000 on PyPI