Registry / testing / pytest-playwright-asyncio

pytest-playwright-asyncio

JSON →
library0.7.2pypypi✓ verified 87d ago

A pytest plugin providing async fixtures for Playwright (via asyncio), enabling async/await browser automation in tests. Current version 0.7.2, requires Python >=3.10. Released as needed; follows pytest-playwright patterns.

pip install pytest-playwright-asyncio
INSTALL
IMPORT
SIG · PYTEST-PLAYWRIGHT-
P
pytest-playwright-asyncio
testingpythonv0.7.2
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

pytest.mark.asyncio
from pytest import mark
No common mistake; use @pytest.mark.asyncio decorator

Basic async test using the page fixture. Ensure you have a conftest.py with the plugin import or set pytest_plugins.

import pytest from playwright.async_api import Page pytest_plugins = ['pytest_playwright_asyncio'] async def test_example(page: Page): await page.goto('https://example.com') assert await page.title() == 'Example Domain'
Debug
Known issues
breakingVersion 0.7.0 dropped support for Python 3.8/3.9 and changed the default fixture scope from function to session. Tests relying on function-level isolation may fail.
fix
If you need function-scoped fixtures, explicitly set scope='function' in conftest.py.
affects: >=0.7.0
gotchaThe 'page' fixture returns a new page in a new context per test by default. Do not reuse pages across tests as they are isolated.
fix
Use the 'context' fixture to share state between pages within a test.
affects: all
deprecatedThe 'browser' fixture is deprecated in favor of 'browser_type' and 'launch_browser' for clarity.
fix
Use 'browser_type.launch()' instead of relying on the 'browser' fixture.
affects: >=0.6.0
Errors
Common errors & fixes
RuntimeError: Event loop is closed
pytest-asyncio mode conflict: using 'auto' or 'strict' mode incorrectly.
fix
Set in pytest.ini: [pytest] asyncio_mode = auto or use @pytest.mark.asyncio explicitly.
ModuleNotFoundError: No module named 'pytest_playwright_asyncio'
pytest cannot find the plugin because it's not installed or not imported in conftest.
fix
Install the package and ensure conftest.py has 'pytest_plugins = ["pytest_playwright_asyncio"]'.
playwright._impl._errors.Error: It looks like you are using Playwright Sync API inside an asyncio test
Using sync Playwright methods (e.g., page.goto() without await) in an async test.
fix
Ensure all Playwright calls are awaited: await page.goto('...')
Upgrade
Version history
0.7.2latest on PyPI · released Nov 24, 2025
Audit
Dependencies
pytestrequiredRequired for fixtures and test discovery
playwrightrequiredRequired for browser automation
pytest-asynciorequiredRequired for async fixture support
Agent activity
6 hits · last 30 days
node
6
Resources
pytest-playwright-asyncio — pip install pytest-playwright-asyncio · libregistry