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.

License PyPI wheel Travis Issues

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

 @pytest.mark.nondestructive
 def test_header_accessibility(selenium, base_url, axe):
     selenium.get(base_url)
     violations = axe.run('header', None, 'critical')
     assert len(violations), axe.report(violations)

The above example runs aXe against only the content within the <header> tag, and filters for violations labeled critical.

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


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-0.0.441.tar.gz (64.1 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-0.0.441-py2.py3-none-any.whl (68.2 kB view details)

Uploaded Python 2Python 3

File details

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

File metadata

File hashes

Hashes for axe-selenium-python-0.0.441.tar.gz
Algorithm Hash digest
SHA256 02ade7404403fc98e86e190805cf02df1850164449b34981d852644f9ea7652f
MD5 40b18f55c56140c5b1fbb9b323023e05
BLAKE2b-256 939b6eafad44389f01e142990220e3cae807d0c11e0ca9da0dd01667ca0cc5de

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for axe_selenium_python-0.0.441-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 31a4a31a56fca0ae40f885a3f82d3501ef53a1cb8772f7c6908a1aaca47bf1df
MD5 7dc5fb1f0d2b65b3b0b86f234f89be98
BLAKE2b-256 6366acf2321281f2d472565e4611ba1ffcc8fca40f59ce8b73c7360eb953387f

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