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

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.

Configuration File

[pytest]
 base_url = http://www.example.com

Command Line Argument

$ pytest --base-url http://www.example.com

Example Test Function

test_accessibility.py

import pytest
import axe_selenium_python
import pytest_axe

@pytest.mark.nondestructive
def test_accessibility(self, axe):

  response = axe.execute()

  assert len(response['violations']) == 0, axe.report()

Tests not using the axe pytest fixture must use the selenium pytest fixture:

test_accessibility.py

import pytest
from axe_selenium_python import Axe

@pytest.mark.nondestructive
def test_accessibility(self, selenium):

  axe = Axe(selenium)
  response = axe.execute()

  assert len(response['violations']) == 0, axe.report()

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.32.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.32-py2.py3-none-any.whl (67.3 kB view details)

Uploaded Python 2Python 3

File details

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

File metadata

File hashes

Hashes for axe-selenium-python-0.0.32.tar.gz
Algorithm Hash digest
SHA256 5cb061e47599f01974ab7e637bc2d024cab0b06c8e27d1ac791b82f216e46f42
MD5 a2c36ae9bf4471e5840dc3bb93da746f
BLAKE2b-256 79014769f90e3d282db912015e1ae03233565c35d74527c688cf1f5d6ab366c1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for axe_selenium_python-0.0.32-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 7caacab8204437aa160586c04a3b052e444c20cbf76466c1d3c09159e322b5f4
MD5 98de227df892313a0241fdf7e5c4abc6
BLAKE2b-256 a10e02267e9af9787406d156039a66793727e3e5d14e57dcf3ec33d24bea665e

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