Registry / testing / axe-selenium-python

axe-selenium-python

JSON →
library2.1.6pypypi✓ verified 35d ago

axe-selenium-python is a Python library designed to integrate the axe-core accessibility testing engine with Selenium WebDriver for automated web accessibility testing. The original project (version 2.1.6) is largely in maintenance mode, with its last significant update in 2018. More actively maintained forks, such as `django-commons/axe-selenium-python` (version 3.0+), provide support for newer Python and Selenium versions and updated axe-core releases.

testing
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

from axe_selenium_python import Axe

Standard Selenium import, not part of axe-selenium-python directly.

from selenium import webdriver

This quickstart demonstrates how to initialize a Selenium WebDriver, inject the axe-core script using `Axe().inject()`, run accessibility checks with `Axe().run()`, and optionally save the results to a JSON file and report violations. It's crucial to have a compatible browser driver (like geckodriver or chromedriver) installed and accessible in your system's PATH.

import os from selenium import webdriver from axe_selenium_python import Axe # Configure a browser (e.g., Firefox or Chrome) # Ensure the appropriate WebDriver (e.g., geckodriver, chromedriver) is in your PATH # For Chrome, you might need: driver = webdriver.Chrome() driver = webdriver.Firefox() try: driver.get("http://www.google.com") axe = Axe(driver) # Inject axe-core javascript into the page axe.inject() # Run axe accessibility checks results = axe.run() # Write results to a JSON file output_dir = "a11y_reports" os.makedirs(output_dir, exist_ok=True) axe.write_results(results, os.path.join(output_dir, 'google_a11y.json')) # Assert no violations are found (optional) if len(results["violations"]) > 0: print("Accessibility Violations Found:") print(axe.report(results["violations"])) # assert False, "Accessibility violations found!" else: print("No accessibility violations found.") finally: driver.quit()
Debug
Known footguns
breakingThe `Axe` class method `execute` was renamed to `run` in version 2.1.5 (or a direct pre-cursor to 2.1.6) to align with the axe-core API. Code using `axe.execute()` will fail.
gotchaThe `axe-selenium-python` package on PyPI, specifically version 2.1.6, is considered to be in maintenance mode, with its last significant update in 2018. For active development, newer Python/Selenium compatibility, and up-to-date axe-core integration (e.g., axe-core@4.x), consider using community-maintained forks like `django-commons/axe-selenium-python` which is more current (e.g., version 3.0+).
gotchaSome functionalities, such as specific helper methods and advanced reporting, were moved to a separate package `pytest-axe` starting from version 2.0.0. If you rely on these features, you will need to install and use `pytest-axe` in conjunction with `axe-selenium-python`.
gotchaThe `axe-selenium-python` library requires a compatible browser WebDriver (e.g., Chromedriver for Chrome, Geckodriver for Firefox) to be installed on your system and available in your system's PATH environment variable. Failure to do so will result in Selenium not being able to launch the browser.
Upgrade
Version history

Breaking-change detection hasn't run for this library yet.

Audit
Security & dependencies

CVE tracking and dependency tree are planned for a later release.

Agent activity
0 hits · last 30 days

No traffic data recorded yet.

Resources