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

Uploaded Source

Built Distribution

File details

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

File metadata

File hashes

Hashes for pytest_axe_playwright_snapshot-0.0.4.tar.gz
Algorithm Hash digest
SHA256 77178ee08acbe094e09708d74720509635420d023269b11729da46f7ca4c7a39
MD5 653e785f7f225b448dc5d41442c617c8
BLAKE2b-256 302c3f910157a2378e93ba6c0cd94b1ca828855be4c6ba87c752ac5defb841b2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pytest_axe_playwright_snapshot-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 951c62b54a42463b106c600f683c45040e5c3698fdd3507603aee412e16a979a
MD5 05915b643ff4b8085e5c19b3c192b566
BLAKE2b-256 cc26c7b484cb87da47427479df5c5e4d4b08e80e06e1c44e3b3a755457b92ddf

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