{"id":7963,"library":"axe-playwright-python","title":"Axe Playwright Python","description":"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.","status":"active","version":"0.1.7","language":"en","source_language":"en","source_url":"https://github.com/pamelafox/axe-playwright-python","tags":["accessibility","playwright","axe-core","testing","a11y"],"install":[{"cmd":"pip install -U axe-playwright-python","lang":"bash","label":"Install library"},{"cmd":"playwright install --with-deps","lang":"bash","label":"Install Playwright browser binaries"}],"dependencies":[{"reason":"Required for running the library.","package":"python","version":">=3.10"},{"reason":"Core dependency for browser automation.","package":"playwright","version":">=1.25.0"}],"imports":[{"symbol":"Axe","correct":"from axe_playwright_python.sync_playwright import Axe"},{"note":"Used for setting up Playwright in synchronous tests.","symbol":"sync_playwright","correct":"from playwright.sync_api import sync_playwright"}],"quickstart":{"code":"from playwright.sync_api import sync_playwright\nfrom axe_playwright_python.sync_playwright import Axe\n\naxe = Axe()\n\nwith sync_playwright() as playwright:\n    browser = playwright.chromium.launch()\n    page = browser.new_page()\n    page.goto(\"https://www.google.com\")\n    results = axe.run(page)\n    browser.close()\n\n    print(f\"Found {results.violations_count} violations.\")\n    if results.violations_count > 0:\n        print(\"Accessibility violations found:\")\n        for violation in results.violations:\n            print(f\"  - {violation['id']}: {violation['description']} (Impact: {violation['impact']})\")\n            print(f\"    Help: {violation['helpUrl']}\")\n    else:\n        print(\"No accessibility violations found.\")","lang":"python","description":"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."},"warnings":[{"fix":"Use `axe.run(page)` from `axe-playwright-python` for accessibility scanning.","message":"Playwright removed its built-in `page.accessibility` API. Users migrating from older Playwright versions or examples might try to use this deprecated method, leading to `AttributeError` or similar errors.","severity":"breaking","affected_versions":"Playwright versions that removed `page.accessibility` (e.g., v1.30+)."},{"fix":"Review changelogs for `axe-playwright-python` and `axe-core` when upgrading. Consider using snapshot testing or baseline reporting tools if strict violation counts are critical for your CI/CD.","message":"Upgrades to the underlying `axe-core` JavaScript engine (which `axe-playwright-python` wraps) can lead to changes in the number, type, or severity of reported accessibility violations. This means test results might differ across `axe-playwright-python` versions even if the application under test remains unchanged.","severity":"gotcha","affected_versions":"All versions, especially when upgrading `axe-playwright-python` across minor or patch releases that update `axe-core`."},{"fix":"Ensure your Python environment is version 3.10 or higher to guarantee full compatibility.","message":"While PyPI classifiers for `axe-playwright-python` indicate compatibility with Python >=3.8, the project's explicit dependencies section specifies `Python >= 3.10`. Users on Python 3.8 or 3.9 might encounter unexpected runtime issues or compatibility problems.","severity":"gotcha","affected_versions":"<=0.1.7"},{"fix":"Ensure that popup blockers are disabled in the browser context used by Playwright, especially for automated testing environments.","message":"Depending on the browser and `axe-core` integration, popup blockers might interfere with `axe.run()` if it attempts to open a new window for analysis. This can lead to the scan failing or hanging.","severity":"gotcha","affected_versions":"All versions, depends on browser configuration and axe-core behavior."}],"env_vars":null,"last_verified":"2026-04-16T00:00:00.000Z","next_check":"2026-07-15T00:00:00.000Z","problems":[{"fix":"Run `pip install axe-playwright-python` and ensure the import statement is `from axe_playwright_python.sync_playwright import Axe`.","cause":"The `axe-playwright-python` package was not installed or the import path is incorrect.","error":"ModuleNotFoundError: No module named 'axe_playwright_python'"},{"fix":"Replace calls to `page.accessibility` with `axe.run(page)` after initializing `Axe()` from `axe_playwright_python`.","cause":"Attempting to use Playwright's removed `page.accessibility` API instead of the `axe-playwright-python` integration.","error":"AttributeError: 'Page' object has no attribute 'accessibility'"},{"fix":"After `results = axe.run(page)`, add an assertion to check `results.violations_count`, for example: `assert results.violations_count == 0`.","cause":"By default, `axe.run(page)` performs a passive scan and does not automatically fail a test if violations are found. You need to explicitly check the results.","error":"Accessibility issues are present but my test is still passing."}]}