Python library to integrate axe and selenium for web accessibility testing.
Project description
axe-selenium-python integrates aXe and selenium to enable automated web accessibility testing.
Requirements
You will need the following prerequisites in order to use axe-selenium-python:
Python 2.7 or 3.6
pytest-selenium >= 3.0.0
geckodriver downloaded and added to your PATH
Optional
tox
Installation
To install axe-selenium-python:
$ pip install axe-selenium-python
To install pytest-axe:
$ pip install pytest-axe
Usage
test_accessibility.py
import pytest
@pytest.mark.nondestructive
def test_header_accessibility(selenium, base_url, axe):
selenium.get(base_url)
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, severe, moderate, 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
Resources
CHANGELOG
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.276
Added pytest-axe usage example to README
version 0.0.275
Added usage example to README
version 0.0.273
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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for axe-selenium-python-1.1.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8096ac35184801f7eb0816a34c98df10f03ec0da39d5bb41bfe156a39df39258 |
|
MD5 | 2bacf2f36282d077424ad9afff246995 |
|
BLAKE2b-256 | 4cba55c70104678c0a8d218b79cf734c6d6d032bd191f3d9b8a61289ae3cb4fe |
Hashes for axe_selenium_python-1.1.1-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 94c31d9cc842fe0fb001d9945e97ec55562e9ec1a35d548b4ef1f403e3eb4cd4 |
|
MD5 | 86a6b1dd47811511770a868dd526d235 |
|
BLAKE2b-256 | 2bfd539b58f630b09be4dd84b92d95902989a9d680b29a08f660950a52a1b3cc |