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
tox
geckodriver downloaded and added to your PATH
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
from axe_selenium_python.test_accessibility import rules, report
@pytest.mark.nondestructive
def test_header_run_axe(selenium, axe, pytestconfig):
pytestconfig.violations = axe.run('header', None, 'critical')
assert pytestconfig.violations is not None
@pytest.mark.nondestructive
@pytest.mark.parametrize('rule', rules)
def test_header_accessibility(rule, pytestconfig):
violations = pytestconfig.violations
assert rule not in violations, report(violations[rule])
The above example is currently the recommended approach. The first test runs axe against the selenium instance, with the context set to <header> and stores the results in pytestconfig.
The second test uses pytest parametrize to generate tests for each rule in the provided list rules.
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.
Command Line Argument
$ pytest --base-url http://www.mozilla.com --driver Firefox test_accessibility.py
Resources
CHANGELOG
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-0.0.43.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 063d15481fdf2961482683b0aea720a224d2aa8b907d2218bf36765cb49d7674 |
|
MD5 | 7fbbe8daa466a50104cdab29f8ecff5c |
|
BLAKE2b-256 | a306ec56ab74c570b468e5f78252739100dbe93653df6296edabaed054b7225d |
Hashes for axe_selenium_python-0.0.43-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9382208be62d41b3a2a7db8b684fed02d0b57c8fac73427e3f85abc05c876bfe |
|
MD5 | e33fb495decdc42b126cf71dc73df403 |
|
BLAKE2b-256 | fab6c44244719f98555918e7e34b8dc84748b036667c9d864d32189afcbef882 |