Skip to main content

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.0.1.

License PyPI Travis wheel Issues Updates Python 3

Requirements

You will need the following prerequisites in order to use axe-selenium-python:

Installation

To install axe-selenium-python:

$ pip install axe-selenium-python

Usage

import pytest
 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.execute()
     # Write results to file
     axe.write_results('a11y.json', results)
     driver.close()
     # Assert no violations are found
     assert len(results["violations"]) == 0, axe.report(results["violations"])

The method axe.execute() 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. You can run the tests using Docker:

$ docker build -t axe-selenium-python .
$ docker run -it axe-selenium-python tox

Resources

CHANGELOG

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.min.js 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.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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

axe-selenium-python-2.0.3.tar.gz (75.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

axe_selenium_python-2.0.3-py2.py3-none-any.whl (77.2 kB view details)

Uploaded Python 2Python 3

File details

Details for the file axe-selenium-python-2.0.3.tar.gz.

File metadata

File hashes

Hashes for axe-selenium-python-2.0.3.tar.gz
Algorithm Hash digest
SHA256 7895698ea369994737ee78edf38e9190d16876c494c710a6fcd6aa91dc6bc74a
MD5 9095adcc91db70031a80b99dde54dc82
BLAKE2b-256 1f2e08beebeb2c53ac37cea4ba1027a86aec73955d78d57b2f2d00865b00461e

See more details on using hashes here.

File details

Details for the file axe_selenium_python-2.0.3-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for axe_selenium_python-2.0.3-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 6959b006cd01c092dad057ce4c7df8ef61826b55b2dc141098005ff3a5b538fa
MD5 61f55ee26828b9b9a2ea2cf428f08ea5
BLAKE2b-256 13143fa923171a5a00e87526bd5df30d3bbfc96168a2ee7a0bb392bed7ddceb1

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page