axe-selenium-python integrates aXe and selenium to enable automated web accessibility testing.
This version of axe-selenium-python is using [email protected].
You will need the following prerequisites in order to use axe-selenium-python:
- selenium >= 3.0.0
- Python 2.7 or 3.6
- geckodriver downloaded and added to your PATH
To install axe-selenium-python:
$ pip install axe-selenium-python
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.