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.
This version of axe-selenium-python is using axe-core@3.1.1.
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:
geckodriver downloaded and added to your PATH
Installation
To install axe-selenium-python:
$ pip install 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
Breaking changes:
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
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
File details
Details for the file axe_selenium-2.1.6.tar.gz
.
File metadata
- Download URL: axe_selenium-2.1.6.tar.gz
- Upload date:
- Size: 91.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 24f0ecd5ae2b171bf36197ece192c39aa24cb04290c6dde02da89f94525a27aa |
|
MD5 | 9d6bb05bd069b1fa7aed9b0951e59731 |
|
BLAKE2b-256 | 1b113387d0c94af91a6c39e40d8ebe58428006d648a6ad8cd671ca72b5e45fcf |
File details
Details for the file axe_selenium-2.1.6-py2.py3-none-any.whl
.
File metadata
- Download URL: axe_selenium-2.1.6-py2.py3-none-any.whl
- Upload date:
- Size: 92.3 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c6dbfe7195d2edb91d61e9b72f63062d0b16e3e9d48e7bc8bc7028adc2fd8857 |
|
MD5 | f55cda0d2569e5bf09428c92d490d7a9 |
|
BLAKE2b-256 | c7b285a89b83ecc7a09cc5f2c3ef155093e0f53efa0484e7cddb123b808a4b3c |