Python library to integrate axe and selenium for web accessibility testing.
Project description
selenium-axe-python
selenium-axe-python integrates aXe and selenium to enable automated web accessibility testing.
Originally created as axe-selenium-python by Kimberly Sereduck. Unfortunately she is no longer assigned to the project which means the original project has gone stale. This is a fork of that project with some updates.
This version of selenium-axe-python is using axe-core@4.9.1
Requirements
You will need the following prerequisites in order to use selenium-axe-python:
-
selenium >= 4.7.0
-
Python 3.9
-
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 selenium-axe-python:
$ pip install selenium-axe-python
Usage
from selenium import webdriver
from selenium_axe_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 jsfile
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
You want to contribute? Great! Here are the things you should do before submitting your PR:
- Fork the repo and git clone your fork.
devinstall the project package:pip install -e .[dev]- Optional (poetry users):
poetry install --extras dev
- Run
toxto perform tests frequently. - Create pull-request from your branch.
The original project required you to run npm install (or in most cases did it at install for you) but this
limited the use of the package to systems that have npm. This fork includes the latest version of
axe-core.
You can run the tests using tox:
$ tox
Alternatively you can use the makefile in the root of the repo:
$ make pre-check-in
Resources
CHANGELOG
version 2.2
- Drop support for python 3.8
version 2.1.18
- Updated axe to
axe-core@4.9.1
version 2.1.17
- adding mypy support (py.typed)
version 2.1.16
- removed old dependencies
version 2.1.15
- updated to work with python >=3.8
- restricted selenium version to 4.x
- Updated axe to
axe-core@4.8.3
version 2.1.12
- forked from original repo axe-selenium-python
- updated to work with python >=3.7
- Updated axe to
axe-core@4.7.2
version 2.1.5
Breaks backwards compatibility:
- The Axe class method
executehas been renamed torunto 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_axehelper methodget_rulesAxe class methodrunAxe class methodimpact_includedAxe class methodanalyzeAxe 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 selenium-axe-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 selenium-axe-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 toresults/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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file selenium_axe_python-2.2.0.tar.gz.
File metadata
- Download URL: selenium_axe_python-2.2.0.tar.gz
- Upload date:
- Size: 166.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1fa570caf984d4b5f81beb5108432212f1505defb18d23e5f8eefbd3def3356a
|
|
| MD5 |
d0830aca4af359499bce8db579c66800
|
|
| BLAKE2b-256 |
a4fb1ca393b5a90e2f46ec3c4dc2797b86f45797f7d630207fe96761e3c328ab
|
Provenance
The following attestation bundles were made for selenium_axe_python-2.2.0.tar.gz:
Publisher:
publish.yml on bandophahita/selenium-axe-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
selenium_axe_python-2.2.0.tar.gz -
Subject digest:
1fa570caf984d4b5f81beb5108432212f1505defb18d23e5f8eefbd3def3356a - Sigstore transparency entry: 173072235
- Sigstore integration time:
-
Permalink:
bandophahita/selenium-axe-python@1a0b8a4004e120d21e74c6ae95f6837b05206d3c -
Branch / Tag:
refs/tags/2.2.0 - Owner: https://github.com/bandophahita
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@1a0b8a4004e120d21e74c6ae95f6837b05206d3c -
Trigger Event:
push
-
Statement type:
File details
Details for the file selenium_axe_python-2.2.0-py3-none-any.whl.
File metadata
- Download URL: selenium_axe_python-2.2.0-py3-none-any.whl
- Upload date:
- Size: 165.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b2c38b419e0cc4589c0b4d5d01938579bb95194eb748873e13cac7014e5546fd
|
|
| MD5 |
663b022f9c44f08a1efb6043c0d1091c
|
|
| BLAKE2b-256 |
653dd7704cca9f220ab954000b13b2c8cb0831b42f0bf1a1b52043cba287136e
|
Provenance
The following attestation bundles were made for selenium_axe_python-2.2.0-py3-none-any.whl:
Publisher:
publish.yml on bandophahita/selenium-axe-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
selenium_axe_python-2.2.0-py3-none-any.whl -
Subject digest:
b2c38b419e0cc4589c0b4d5d01938579bb95194eb748873e13cac7014e5546fd - Sigstore transparency entry: 173072237
- Sigstore integration time:
-
Permalink:
bandophahita/selenium-axe-python@1a0b8a4004e120d21e74c6ae95f6837b05206d3c -
Branch / Tag:
refs/tags/2.2.0 - Owner: https://github.com/bandophahita
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@1a0b8a4004e120d21e74c6ae95f6837b05206d3c -
Trigger Event:
push
-
Statement type: