Skip to main content

A pytest plugin for playwright python

Project description

version codecov docs

pytest-playwright-enhanced

[!CAUTION] pytest-playwright-enhanced is in the alpha stage.

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.
  • Asynchronous support.
  • Custom hooks to 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-enhanced
  • pytest <posargs> --acquire-binaries=with-deps

Overriding Browser and Context args

...


Fixtures


  • pw_playwright - At present this returns the sync Playwright instance.
  • pw_multi_browser - Automatically run a test on chromium, firefox and webkit.
  • pw_headed - Returns if the browser is running headlessly or not.
  • pw_slow_mo - Returns the currently throttle in milliseconds, defaults to 0.
  • 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 by Page objects.
  • pw_browser - Returns the current Browser instance.
  • pw_browser_engine - A string representing the type of browser for this test.
  • pw_context_kwargs - An overridable fixture to control arguments to playwright Context instances.
  • pw_page - Returns a new Page instance.
  • pw_is_debugging - Returns if playwright will be using PW_DEBUG mode.
  • 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.


Markers

  • @pytest.mark.only_on_browsers - Only run on a subset of browsers when using the pw_multi_browser fixture.
  • @pytest.mark.context_kwargs - Per test level overrides to the context object.
  • @pytest.mark.browser_kwargs - Per test level overrides to the browser object.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pytest_playwright_enhanced-0.1.6.tar.gz (17.9 kB view details)

Uploaded Source

Built Distribution

pytest_playwright_enhanced-0.1.6-py3-none-any.whl (20.8 kB view details)

Uploaded Python 3

File details

Details for the file pytest_playwright_enhanced-0.1.6.tar.gz.

File metadata

  • Download URL: pytest_playwright_enhanced-0.1.6.tar.gz
  • Upload date:
  • Size: 17.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.2 CPython/3.12.2 Linux/6.5.0-1016-azure

File hashes

Hashes for pytest_playwright_enhanced-0.1.6.tar.gz
Algorithm Hash digest
SHA256 ff0bef64cd1e92be98c3dec35102ae598482748ac9b5dbf2fb28804e1aa3e0b9
MD5 ab46274e963118079a524ed9d9b37dd1
BLAKE2b-256 1b717f75655abeb8b40e83e71427eab8cfb1fb68e8323b91271ac179958cd745

See more details on using hashes here.

File details

Details for the file pytest_playwright_enhanced-0.1.6-py3-none-any.whl.

File metadata

File hashes

Hashes for pytest_playwright_enhanced-0.1.6-py3-none-any.whl
Algorithm Hash digest
SHA256 0d9f7e2cf6999068ba14d6610ded3a86040e1301e9d6c6750e85d782c5cba869
MD5 ab0da98a3f5cdf2177aa3753be7e741d
BLAKE2b-256 6a3b45d1ce6b54994b974c2578d248a4cf531edf8a6b8b33184386bad50b6e41

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page