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.3.tar.gz (5.9 kB view details)

Uploaded Source

Built Distribution

File details

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

File metadata

File hashes

Hashes for pytest_axe_playwright_snapshot-0.0.3.tar.gz
Algorithm Hash digest
SHA256 d87918a24f07741393a0c47a8662b3a5cd41a0ba7108ba737d9df9b204e9d45c
MD5 c7510827a784afbe124d6ec5f45e7919
BLAKE2b-256 0f64bf5b1d54850790b6fadd2cc72472031312842551fd3d3c76f62b4ce78a85

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pytest_axe_playwright_snapshot-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 1192e7ef52c8bc3465028ea9ae32bb79f1933a37b5b1ade6f39a837fa36b6392
MD5 04eb346f7ec7c14f60fa8b4e6bc3ad8c
BLAKE2b-256 d75c6206a01a96e6af040329db32c87847492536759d20bebd7b42f3fa297fb0

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