Spaces:
Runtime error
Runtime error
Create my_axe_test.py
Browse files- my_axe_test.py +16 -0
my_axe_test.py
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from selenium import webdriver
|
| 2 |
+
from axe_selenium_python import Axe
|
| 3 |
+
|
| 4 |
+
def test_google():
|
| 5 |
+
driver = webdriver.Chrome()
|
| 6 |
+
driver.get("http://www.google.com")
|
| 7 |
+
axe = Axe(driver)
|
| 8 |
+
# Inject axe-core javascript into page.
|
| 9 |
+
axe.inject()
|
| 10 |
+
# Run axe accessibility checks.
|
| 11 |
+
results = axe.run()
|
| 12 |
+
# Write results to file
|
| 13 |
+
axe.write_results(results, 'a11y.json')
|
| 14 |
+
driver.close()
|
| 15 |
+
# Assert no violations are found
|
| 16 |
+
assert len(results["violations"]) == 0, axe.report(results["violations"])
|