Get Started with Playwright (Python)
Getting started takes four steps: install the packages, install the browsers, write a test, and run pytest. The plugin auto-registers through a pytest11 entry point, so there is no conftest.py wiring to add.
- For AI agents
- For Human
Paste this prompt into your coding agent:
Setup prompt
Add TestRelic analytics to this Playwright Python project.
1. Install the packages: pip install pytest-playwright testrelic-playwright
2. Install the browsers: playwright install
3. Add a simple Playwright test under tests/ that uses the `page` fixture.
4. Do NOT add any conftest.py wiring or imports — the plugin auto-registers
via its pytest11 entry point.
5. Run `pytest` and open test-results/analytics-timeline.html to confirm the
report was generated.
-
Install the packages:
Terminalpip install pytest-playwright testrelic-playwright -
Install the Playwright browsers:
Terminalplaywright install -
Write a test:
tests/test_homepage.pyfrom playwright.sync_api import Page, expect
def test_homepage_loads(page: Page) -> None:
page.goto("https://example.com")
expect(page.locator("h1")).to_be_visible() -
Run your tests:
Terminalpytest -
Open the report at
test-results/analytics-timeline.html.
Full quickstart
Terminal
pip install pytest-playwright testrelic-playwright
playwright install
pytest
note
There is nothing to import and no conftest.py to edit. As long as testrelic-playwright is installed in the same environment as pytest, the plugin is active automatically.
Output files
A run writes the analytics timeline into test-results/:
test-results/
├── analytics-timeline.json
└── analytics-timeline.html
Open analytics-timeline.html in any browser for the interactive report. Outside of CI the report opens automatically when the run finishes.
Requirements
| Requirement | Version |
|---|---|
| Python | >=3.9 |
| pytest | >=7.0 |
| pytest-playwright | >=0.5.0 |
| playwright | >=1.35 |
| httpx | >=0.27 |