pytest plugin for axe-selenium-python
Project description
Pytest plugin for axe-selenium-python. pytest-axe adds a pytest fixture for Axe objects, to simplify running accessibility checks. Using this fixture requires the use of pytest-selenium.
pytest-axe also includes a command line option, --axe, to keep accessibility tests separate from functional tests.
Requirements
You will need the following prerequisites in order to use pytest-axe:
Python 2.7 or 3.6
pytest-selenium >= 3.0.0
axe-selenium-python
Installation
To install pytest-axe:
$ pip install pytest-axe
Usage
To run tests using pytest-selenium (a dependency of axe-selenium-python), tests must be marked with the non-destructive pytest decorator:
@pytest.mark.nondestructive
def test_my_test_function():
assert true
Test suites using axe-selenium-python must import pytest and the Axe class.
pytest-selenium relies on the base_url fixture, which can be set in a configuration file, or as a command line argument.
[pytest]
base_url = http://www.example.com
$ pytest --base-url http://www.example.com
aXe Command Line Option
The @pytest.mark.accessibility marker must be added to all accessibility tests.
To run only non-accessibility tests, run pytest as usual. To run only accessibility tests, add --axe to your pytest command(s).
Example Test Function
test_accessibility.py
import pytest
from axe_selenium_python import Axe
import pytest_axe
@pytest.mark.nondestructive
def test_accessibility(self, axe):
response = axe.execute()
assert len(response['violations']) == 0, axe.report()
Resources
CHANGELOG
Version 0.2.0
Added a command line argument to filter tests based on the presence or absence of a pytest accessibility marker.
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 pytest_axe-0.2.2-py2-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8c42be99f4daa456a5cd3b180f23157548b5ab2d478f81de7cff4454d231368b |
|
MD5 | 4643421cf63b1f6d26eabb0e76604ca5 |
|
BLAKE2b-256 | 0c22c943ad6a4b9d85ded268912b44ba69d1d7664904f3565cf11cbad3974b48 |