Python library to integrate axe and selenium for web accessibility testing.
axe-selenium-python integrates aXe and selenium to enable automated web accessibility testing.
This version of axe-selenium-python is using firstname.lastname@example.org.
You will need the following prerequisites in order to use axe-selenium-python:
To install axe-selenium-python:
$ pip install axe-selenium-python
To install pytest-axe:
$ pip install pytest-axe
import pytest @pytest.mark.nondestructive def test_header_accessibility(axe): violations = axe.run('header', None, 'critical') assert len(violations) == 0, axe.report(violations)
The above example runs aXe against only the content within the <header> tag, and filters for violations labeled critical.
The method axe.run() accepts three parameters: context, options, and impact.
For more information on context and options, view the aXe documentation here.
The third parameter, impact, allows you to filter violations by their impact level. The options are 'critical', 'serious' and 'minor', with the default value set to None.
This will filter violations for the impact level specified, and all violations with a higher impact level.
To run the above test you will need to specify the browser instance to be invoked, and the base_url.
$ pytest --base-url http://www.mozilla.com --driver Firefox test_accessibility.py
- 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.
- Updated axe.min.js to email@example.com
- Modified impact_included class method to reflect changes to the aXe API:
- There are now only 3 impact levels: ‘critical’, ‘serious’, and ‘minor’
- Updated usage examples in README
- Added docstrings to methods lacking documentation
- Removed unused files
- 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’
- Added pytest-axe usage example to README
- Added usage example to README
- Added selenium instance as a class attribute
- Changed file paths to OS independent structure
- Fixed file read operations to use with keyword
- Fixed include of aXe API file and references to it
- Updated README
Release history Release notifications
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
|Filename, size & hash SHA256 hash help||File type||Python version||Upload date|
|axe_selenium_python-1.2.4-py2.py3-none-any.whl (69.4 kB) Copy SHA256 hash SHA256||Wheel||py2.py3|
|axe-selenium-python-1.2.4.tar.gz (67.5 kB) Copy SHA256 hash SHA256||Source||None|