pytest-playwright

0.7.2 · active · verified Thu Apr 09

pytest-playwright is a Pytest plugin that provides robust fixtures for Playwright, enabling efficient end-to-end web testing in Python. It automatically manages browser instances, contexts, and pages, integrating seamlessly with the pytest testing framework. As of version 0.7.2, it supports Playwright Python 1.39.0 and higher, with new versions typically released in sync with Playwright's own update cadence.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates a basic web test using the `page` fixture provided by pytest-playwright. It navigates to Google, asserts the title, and takes a screenshot.

import pytest

def test_example_is_working(page):
    page.goto("https://www.google.com")
    assert "Google" in page.title()
    page.screenshot(path="screenshot.png")

# To run this test file:
# 1. Save as e.g., `test_my_app.py`
# 2. Ensure browsers are installed: `playwright install`
# 3. Run: `pytest test_my_app.py`

view raw JSON →