{"id":7027,"library":"axe-selenium-python","title":"axe-selenium-python","description":"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.","status":"maintenance","version":"2.1.6","language":"en","source_language":"en","source_url":"https://github.com/mozilla-services/axe-selenium-python","tags":["accessibility","testing","selenium","axe-core","web-testing"],"install":[{"cmd":"pip install axe-selenium-python","lang":"bash","label":"Install latest 2.x version"}],"dependencies":[{"reason":"Required for browser automation.","package":"selenium","optional":false},{"reason":"WebDriver executable for the target browser must be installed and available in system PATH or specified explicitly.","package":"web browser driver (e.g., chromedriver, geckodriver)","optional":false}],"imports":[{"symbol":"Axe","correct":"from axe_selenium_python import Axe"},{"note":"Standard Selenium import, not part of axe-selenium-python directly.","symbol":"webdriver","correct":"from selenium import webdriver"}],"quickstart":{"code":"import os\nfrom selenium import webdriver\nfrom axe_selenium_python import Axe\n\n# Configure a browser (e.g., Firefox or Chrome)\n# Ensure the appropriate WebDriver (e.g., geckodriver, chromedriver) is in your PATH\n# For Chrome, you might need: driver = webdriver.Chrome()\ndriver = webdriver.Firefox()\n\ntry:\n    driver.get(\"http://www.google.com\")\n\n    axe = Axe(driver)\n\n    # Inject axe-core javascript into the page\n    axe.inject()\n\n    # Run axe accessibility checks\n    results = axe.run()\n\n    # Write results to a JSON file\n    output_dir = \"a11y_reports\"\n    os.makedirs(output_dir, exist_ok=True)\n    axe.write_results(results, os.path.join(output_dir, 'google_a11y.json'))\n\n    # Assert no violations are found (optional)\n    if len(results[\"violations\"]) > 0:\n        print(\"Accessibility Violations Found:\")\n        print(axe.report(results[\"violations\"]))\n        # assert False, \"Accessibility violations found!\"\n    else:\n        print(\"No accessibility violations found.\")\n\nfinally:\n    driver.quit()","lang":"python","description":"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."},"warnings":[{"fix":"Replace calls to `axe.execute()` with `axe.run()`.","message":"The `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.","severity":"breaking","affected_versions":">=2.1.5"},{"fix":"For new projects or if encountering compatibility issues with modern Python/Selenium, evaluate using `pip install django-commons-axe-selenium-python` (check the exact package name as forks might vary) and adjust imports if necessary (e.g., `from django_commons_axe_selenium_python import Axe`). Always refer to the latest fork's documentation.","message":"The `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+).","severity":"gotcha","affected_versions":"All 2.x versions"},{"fix":"Install `pytest-axe` (`pip install pytest-axe`) and consult its documentation for moved functionalities.","message":"Some 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`.","severity":"gotcha","affected_versions":">=2.0.0"},{"fix":"Download the appropriate WebDriver for your browser and operating system (e.g., from `chromedriver.chromium.org` or `github.com/mozilla/geckodriver/releases`), place the executable in a directory, and add that directory to your system's PATH.","message":"The `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.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-16T00:00:00.000Z","next_check":"2026-07-15T00:00:00.000Z","problems":[{"fix":"Download `chromedriver` from `chromedriver.chromium.org` and place the executable in a directory that is included in your system's PATH environment variable. Alternatively, specify the `executable_path` when initializing the Chrome driver: `webdriver.Chrome(executable_path='/path/to/chromedriver')`.","cause":"Selenium cannot find the executable for the Chrome browser driver because it's not in the system's PATH.","error":"WebDriverException: Message: 'chromedriver' executable needs to be in PATH."},{"fix":"Ensure that the elements you wish to test are visible and fully loaded on the page before calling `axe.inject()` and `axe.run()`. Use Selenium's explicit waits (`WebDriverWait`) to ensure elements are present and visible. Review the `context` and `options` passed to `axe.run()` to ensure they are not inadvertently excluding relevant parts of the page.","cause":"Axe-core might not be able to detect violations for elements that are hidden or not fully rendered when `axe.inject()` or `axe.run()` is called. This can also happen if the `context` or `options` parameters are too restrictive.","error":"Getting empty results even though there are violations on the page"},{"fix":"Update your code to use `axe.run()` instead of `axe.execute()`.","cause":"Attempting to call the `execute` method on the `Axe` object, which was renamed to `run`.","error":"AttributeError: 'Axe' object has no attribute 'execute'"}]}