mozilla-services / axe-selenium-python

aXe Selenium Integration python package
https://pypi.python.org/pypi/axe-selenium-python/
Mozilla Public License 2.0
58 stars 50 forks source link

axe-selenium-python

axe-selenium-python integrates aXe and selenium to enable automated web accessibility testing.

This version of axe-selenium-python is using axe-core@4.0.2.

.. image:: https://img.shields.io/badge/license-MPL%202.0-blue.svg :target: https://github.com/mozilla-services/axe-selenium-python/blob/master/LICENSE.txt :alt: License .. image:: https://img.shields.io/pypi/v/axe-selenium-python.svg :target: https://pypi.org/project/axe-selenium-python/ :alt: PyPI .. image:: https://img.shields.io/travis/mozilla-services/axe-selenium-python.svg :target: https://travis-ci.org/mozilla-services/axe-selenium-python :alt: Travis .. image:: https://img.shields.io/github/issues-raw/mozilla-services/axe-selenium-python.svg :target: https://github.com/mozilla-services/axe-selenium-python/issues :alt: Issues .. image:: https://api.dependabot.com/badges/status?host=github&repo=mozilla-services/axe-selenium-python :target: https://dependabot.com :alt: Dependabot .. image:: https://coveralls.io/repos/github/mozilla-services/axe-selenium-python/badge.svg?branch=master :target: https://coveralls.io/github/mozilla-services/axe-selenium-python?branch=master :alt: Coveralls

Requirements

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

Installation

To install axe-selenium-python:

.. code-block:: bash

$ pip install axe-selenium-python

Usage

.. code-block:: python

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 <https://github.com/dequelabs/axe-core/blob/master/doc/API.md#parameters-axerun>_.

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 <https://tox.readthedocs.io/en/latest/>_:

.. code-block:: bash

$ tox

Resources

CHANGELOG ^^^^^^^^^^^^^^

version 2.1.5


Breaks backwards compatibility:

version 2.1.0


version 2.0.0


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


version 1.2.1


version 1.0.0


version 0.0.3


version 0.0.28


version 0.0.21