pytest-playwright-enhanced
pytest-playwright-enhanced is a batteries included pytest plugin for the playwright python bindings that
offers extended functionality with a focus on removing boilerplate code for projects that wish to test modern
web applications and APIs. pytest-playwright-enhanced plans to offer the following:
- Automatic, browser management and installation if required (TBD)
- Improved, human readable APIs that build on top of playwrights API.
- Improved artifacting and debugability.
Asynchronoussupport.- Custom
hooksto allow you to plugin and modify behaviour at runtime. - Much More...
pytest-playwright-enhanced is currently implementing core plugin functionality, the main enhancements
will follow shortly.
pytest-playwright-enhanced right now treats browsers, contexts and pages at a function level. This allows
easily per test overrides at the small cost of slightly less performance creating browsers, for now it is worth it
as it offers much more flexibility and user defined configurations.
Quick Start
Quickly get running by doing the following:
pip install pytest-playwright-enhancedpytest <posargs> --acquire-binaries=with-deps
Overriding Browser and Context args
There are two methods for overwriting both browser and context arguments at runtime. These are:
import pytest
import typing
@pytest.mark.browser_kwargs(env={}, timeout=15)
@pytest.mark.context_kwargs()
def test_my_app(pw_page):
# This page will have a preconfigured browser and context from the
# marker arguments.
...
def my_function(config: pytest.Config) -> dict[typing.Any, typing.Any]:
return {
# custom options.
# inspect CLI if you need via config.
}
# if you need to calculate the args at runtime, later use:
@pytest.mark.browser_kwargs(callback=my_function)
@pytest.mark.context_kwargs(callback=my_function)
def test_my_app(pw_page):
# internal machinery will invoke `my_function_that_returns_kwargs`
# later to get overrides. These are merged sensible with CLI and
# other PWE defaults.
...
Alternatively, if you need more dynamicism, overwrite the fixture and take full control:
import pytest
import typing
@pytest.fixture(scope="function")
def pw_browser_contexts(config: pytest.Config) -> dict[typing.Any, typing.Any]:
return {
# Any overrides here,
# ...
}
Fixtures
pw_playwright- At present this returns the syncPlaywrightinstance.pw_multi_browser- Automatically run a test onchromium,firefoxandwebkit.pw_headed- Returns if the browser is running headlessly or not.pw_slow_mo- Returns the currently throttle in milliseconds, defaults to0.pw_is_chromium- Returns if the current browser is chromium.pw_is_webkit- Returns if the current browser is webkit.pw_is_firefox- Returns if the current browser is firefox.pw_root_url- Returns the base url auto loaded byPageobjects.pw_browser- Returns the currentBrowserinstance.pw_browser_engine- A string representing the type of browser for this test.pw_context- A playwright syncContextobject, useful for multi page scenarios.pw_context_kwargs- An overridable fixture to control arguments to playwrightContextinstances.pw_page- Returns a newPageinstance.pw_is_debugging- Returns if playwright will be usingPW_DEBUGmode.pw_browser_kwargs- An overridable fixture to control arguments to playwright `Browser nstances.
Hooks
pytest_playwright_acquire_binaries: Hook in and customise binary acquisition at runtime.
pytest_playwright_is_debugging: User defined behaviour for detecting if an IDE is debugging.
pytest_playwright_browser_env: Control the environment passed on to playwright browser instances.
pytest_playwright_configure_proxy: Return a ProxySettings object in your own hooks to control proxy settings.
Markers
@pytest.mark.only_on_browsers- Only run on a subset of browsers when using thepw_multi_browserfixture.@pytest.mark.context_kwargs- Per test level overrides to thecontextobject.@pytest.mark.browser_kwargs- Per test level overrides to thebrowserobject.
Metadata
Release files for pytest-playwright-enhanced 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pytest_playwright_enhanced-0.2.0.tar.gz | 19.4 kB | Without provenance | Details for pytest_playwright_enhanced-0.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pytest_playwright_enhanced-0.2.0-py3-none-any.whl | Python 3 | none | any | Details for pytest_playwright_enhanced-0.2.0-py3-none-any.whl |
Total release size: 41.5 kB
Release files / pytest_playwright_enhanced-0.2.0.tar.gz
| Download URL | pytest_playwright_enhanced-0.2.0.tar.gz |
|---|---|
| Size | 19.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
36ae84be2762b9c0b196a89bb767116b4096ac1c779e283f8fef5172f89512c8
|
|
BLAKE2b-256 checksum How to use checksums |
9a5e7ca9415732471779cab39ffe9f3019ed2142cdd29cb629e154737d2ec2dd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.8.2 CPython/3.12.2 Linux/6.5.0-1016-azure
|
Release files / pytest_playwright_enhanced-0.2.0-py3-none-any.whl
| Download URL | pytest_playwright_enhanced-0.2.0-py3-none-any.whl |
|---|---|
| Size | 22.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ce644b9e56fc34d1b9606c04e3c570cb3983443581ffd8e49ec0d8fadc30e36a
|
|
BLAKE2b-256 checksum How to use checksums |
2d91b4c4837bbbccf3ea230442a1bb79a46f424c7b689b36070c4bae84a2f263
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.8.2 CPython/3.12.2 Linux/6.5.0-1016-azure
|
Security for pytest-playwright-enhanced 0.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.