Axe Playwright Python

0.1.7 · active · verified Thu Apr 16

Axe Playwright Python facilitates automated web accessibility testing by integrating the axe-core engine with Playwright. It allows developers to scan web pages for accessibility violations within their Playwright test suites. The current version is 0.1.7. Release cadence appears to be irregular, with updates typically occurring every few months based on the project's changelog, often driven by updates to the underlying axe-core JavaScript library.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to initialize Axe, launch a Playwright browser, navigate to a page, run an accessibility scan, and print the number of violations. It also includes an example of iterating through detected violations.

from playwright.sync_api import sync_playwright
from axe_playwright_python.sync_playwright import Axe

axe = Axe()

with sync_playwright() as playwright:
    browser = playwright.chromium.launch()
    page = browser.new_page()
    page.goto("https://www.google.com")
    results = axe.run(page)
    browser.close()

    print(f"Found {results.violations_count} violations.")
    if results.violations_count > 0:
        print("Accessibility violations found:")
        for violation in results.violations:
            print(f"  - {violation['id']}: {violation['description']} (Impact: {violation['impact']})")
            print(f"    Help: {violation['helpUrl']}")
    else:
        print("No accessibility violations found.")

view raw JSON →