Skip to main content

axe-selenium-python integrates aXe and selenium to enable automated web accessibility testing.

This version of axe-selenium-python is using axe-core@3.3.2.

License PyPI Travis Issues Dependabot Coveralls

Requirements

You will need the following prerequisites in order to use axe-selenium-python:

  • selenium >= 3.0.0

  • Python 2.7 or 3.6

  • The appropriate driver for the browser you intend to use, downloaded and added to your path, e.g. geckodriver for Firefox:

Installation

To install axe-selenium-python:

$ pip install rh-axe-selenium-python

Usage

from selenium import webdriver
from axe_selenium_python import Axe

def test_google():
    driver = webdriver.Firefox()
    driver.get("http://www.google.com")
    axe = Axe(driver)
    # Inject axe-core javascript into page.
    axe.inject()
    # Run axe accessibility checks.
    results = axe.run()
    # Write results to file
    axe.write_results(results, 'a11y.json')
    driver.close()
    # Assert no violations are found
    assert len(results["violations"]) == 0, axe.report(results["violations"])

The method axe.run() accepts two parameters: context and options.

For more information on context and options, view the aXe documentation here.

Contributing

Fork the repository and submit PRs with bug fixes and enhancements; contributions are very welcome.

Node dependencies must be installed by running npm install inside the axe-selenium-python directory.

You can run the tests using tox:

$ tox

Resources

CHANGELOG

version 2.1.5

Breaks backwards compatibility:

  • The Axe class method execute has been renamed to run to mirror the method in the axe-core API.

version 2.1.0

  • Created package.json file to maintain axe-core dependency

  • Replaced unit tests with more meaningful integration tests - included a sample html file for integration tests

version 2.0.0

  • All functionalities that are not part of axe-core have been moved into a separate package, pytest-axe. This includes:

    • run_axe helper method

    • get_rules Axe class method

    • run Axe class method

    • impact_included Axe class method

    • analyze Axe class method.

The purpose of this change is to separate implementations that are specific to the Mozilla Firefox Test Engineering team, and leave the base axe-selenium-python package for a more broad use case. This package was modeled off of Deque’s Java package, axe-selenium-java, and will now more closely mirror it.

All functionalities can still be utilized when using axe-selenium-python in conjunction with pytest-axe.

version 1.2.3

  • Added the analyze method to the Axe class. This method runs accessibility checks, and writes the JSON results to file based on the page URL and the timestamp.

  • Writing results to file can be enabled by setting the environment variable ACCESSIBILITY_REPORTING=true. The files will be written to results/ directory, which must be created if it does not already exist.

  • Accessibility checks can be disabled by setting the environment variable ACCESSIBILITY_DISABLED=true.

version 1.2.1

  • Updated axe to axe-core@2.6.1

  • Modified impact_included class method to reflect changes to the aXe API:

  • There are now only 3 impact levels: ‘critical’, ‘serious’, and ‘minor’

version 1.0.0

  • Updated usage examples in README

  • Added docstrings to methods lacking documentation

  • Removed unused files

version 0.0.3

  • Added run method to Axe class to simplify the usage in existing test suites

  • run method includes the ability to set what impact level to test for: ‘minor’, ‘moderate’, ‘severe’, ‘critical’

version 0.0.28

  • Added selenium instance as a class attribute

  • Changed file paths to OS independent structure

  • Fixed file read operations to use with keyword

version 0.0.21

  • Fixed include of aXe API file and references to it

  • Updated README

Release files for rh-axe-selenium-python 21.5.19.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for rh-axe-selenium-python 21.5.19.2
File Size Uploaded
rh-axe-selenium-python-21.5.19.2.tar.gz 180.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for rh-axe-selenium-python 21.5.19.2
File Interpreter ABI Platform
rh_axe_selenium_python-21.5.19.2-py2.py3-none-any.whl Python 2, Python 3 none any Details

Total release size: 357.6 kB

Release files / rh-axe-selenium-python-21.5.19.2.tar.gz

Download URL rh-axe-selenium-python-21.5.19.2.tar.gz
Size 180.0 kB
Tags Source
SHA-256 checksum
How to use checksums
f06283003c37b62c977d79f06c462a3447d74a32f6fa2cfdddae96c34606ae79
BLAKE2b-256 checksum
How to use checksums
caeec7645c5fb91c9b38ef78046a183a7049be1430904ade7d4df366c839a23a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.5

Release files / rh_axe_selenium_python-21.5.19.2-py2.py3-none-any.whl

Download URL rh_axe_selenium_python-21.5.19.2-py2.py3-none-any.whl
Size 177.6 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
329882b768e007d10ed6e1f4cc1c1605d05d77d4e8e3de045eab194b50d42a75
BLAKE2b-256 checksum
How to use checksums
fc6a92542a3be1bcf08a896ccfa14bccee19fb6e794e8fabf18a841b595c3a50
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.5

Release history Release notifications | RSS feed

This release

21.5.19.2 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page