Skip to main content

A pytest plugin that runs Axe-core on Playwright pages and takes snapshots of the results.

Project description

pytest-axe-playwright-snapshot

A pytest plugin that runs Axe-core on Playwright pages and takes snapshots of the results.

Installation

  1. Install the plugin:

    python3 -m pip install pytest-axe-playwright-snapshot
    
  2. Install Playwright browsers:

    python3 -m playwright install --with-deps
    

Usage

In your tests, use the page fixture from pytest-playwright along with our plugin'saxe_pytest_snapshot fixture. Once you've navigated to a page, call axe_pytest_snapshot with the page fixture as an argument:

from playwright.sync_api import Page

def test_violations(page: Page, axe_pytest_snapshot):
    page.goto("https://www.example.com")
    axe_pytest_snapshot(page)

When you run a test for the first time, you must tell it explicitly to save a snapshot:

pytest --snapshot-update

The plugin will take a snapshot of the page and save it to a file in the snapshots directory. The snapshot directory will be named after the test function, and the file will be named 'violations.txt'.

On subsequent runs, the plugin will compare the latest snapshot against the snapshot and report any difference in the violations.

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_axe_playwright_snapshot-0.0.6.tar.gz (6.8 kB view details)

Uploaded Source

Built Distribution

File details

Details for the file pytest_axe_playwright_snapshot-0.0.6.tar.gz.

File metadata

File hashes

Hashes for pytest_axe_playwright_snapshot-0.0.6.tar.gz
Algorithm Hash digest
SHA256 b9844487d73f5f0fd129e7ced998fad20e73e94c2074d7e2d0fdd69e069d4c82
MD5 55d53581d7903987ebd98ebec49da768
BLAKE2b-256 e611c0e6c2d1e56d374eb363492de5844f14bd49a07a36a8eb40bed5b857d953

See more details on using hashes here.

File details

Details for the file pytest_axe_playwright_snapshot-0.0.6-py3-none-any.whl.

File metadata

File hashes

Hashes for pytest_axe_playwright_snapshot-0.0.6-py3-none-any.whl
Algorithm Hash digest
SHA256 74702e978ddfbce5ac5c675d30a4ce0b743c982a3cfe70a3a4c05ac2c1b7c70c
MD5 b8f519c8bfb14f8679454f0cd8df6cc0
BLAKE2b-256 702e8c330adef5d038af3a9a0488247ec73d3cf4804dd49ac84cdf15267b87b1

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