Skip to content

Commit 940fc00

Browse files
author
Kimberly Pennington
committed
initial commit
0 parents  commit 940fc00

File tree

5 files changed

+143
-0
lines changed

5 files changed

+143
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
*.pyc

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# aXe Selenium (Python) Integration README

axe-selenium-python/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# This Source Code Form is subject to the terms of the Mozilla Public
2+
# License, v. 2.0. If a copy of the MPL was not distributed with this
3+
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

axe-selenium-python/axe.py

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
# This Source Code Form is subject to the terms of the Mozilla Public
2+
# License, v. 2.0. If a copy of the MPL was not distributed with this
3+
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
4+
5+
6+
class Axe:
7+
8+
def get_contents(script):
9+
"""
10+
Return contents of the axe.js or axe.min.js script.
11+
12+
:param script: URL of the axe-core script.
13+
:type script: string
14+
:return: contents of script.
15+
:rtype: string
16+
"""
17+
18+
def inject(driver, script_url):
19+
"""
20+
Recursively inject aXe into all iframes and the top level document.
21+
22+
:param driver: WebDriver instance to inject script into.
23+
:param script_url: URL of the axe-core script.
24+
:type driver: WebDriver
25+
:type script_url: string
26+
"""
27+
28+
def inject_into_frames(driver, script, parents):
29+
"""
30+
Recursively find frames and inject a script into them.
31+
32+
:param driver: WebDriver instance to inject script into.
33+
:param script: Script to inject.
34+
:type driver: WebDriver
35+
:type script: string
36+
"""
37+
38+
def report(violations):
39+
"""
40+
??? Do we want this functionality in our package?
41+
42+
Return readable report of accessibility violations found.
43+
44+
:param violations: Dictionary of violations.
45+
:type violations: dict
46+
:return report: Readable report of violations.
47+
:rtype: string
48+
"""
49+
50+
def write_results(name, output):
51+
"""
52+
Write JSON to file with the specified name.
53+
54+
:param name: Name of file to be written to.
55+
:param output: JSON object.
56+
"""
57+
58+
class Builder:
59+
"""
60+
Chainable builder for invoking aXe. Instantiate a new Builder and
61+
configure testing with the include(), exclude(), and options() methods
62+
before calling analyze() to run.
63+
64+
driver (WebDriver)
65+
script (string): URL of script
66+
includes (list): list of selectors to include.
67+
excludes (list): list of selectors to exclude.
68+
options (dict): Dictionary of aXe configuration options.
69+
"""
70+
71+
def __init__(driver, script):
72+
"""
73+
Inject the aXe script into the WebDriver.
74+
:param driver: An intialized WebDriver.
75+
:param script: URL of aXe script.
76+
:type driver: WebDriver
77+
:type script: string
78+
""""
79+
80+
def options(options):
81+
"""
82+
Set the aXe options.
83+
84+
:param options: Dictionary of aXe configuration options.
85+
:type options: dict
86+
"""
87+
88+
def include(selector):
89+
"""
90+
Include a selector.
91+
92+
:param selector: any valid CSS selector.
93+
:type selector: string
94+
"""
95+
96+
def exclude(selector):
97+
"""
98+
Exclude a selector.
99+
100+
:param selector: any valid CSS selector.
101+
:type selector: string
102+
"""
103+
104+
def analyze():
105+
"""
106+
Run aXe against the page.
107+
108+
:return results: Dictionary of JSON results.
109+
:rtype results: dict
110+
"""
111+
112+
def analyze_element(context):
113+
"""
114+
Rune aXe against a specific WebElement.
115+
116+
:param context: Web element to be analyzed.
117+
:type context: WebElement
118+
:return results: aXe JSON results
119+
:rtype: dict
120+
"""

axe-selenium-python/setup.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# This Source Code Form is subject to the terms of the Mozilla Public
2+
# License, v. 2.0. If a copy of the MPL was not distributed with this
3+
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
4+
5+
6+
from setuptools import setup
7+
8+
setup(name='axe-selenium-python',
9+
version='0.1',
10+
description='Python library to integrate axe and selenium for web \
11+
accessibility testing.',
12+
url='http://github.com/kimberlythegeek/axe-selenium-python',
13+
author='Kimberly Pennington',
14+
license='MPL',
15+
packages=['axe-selenium-python'],
16+
install_requires=[
17+
],
18+
zip_safe=False)

0 commit comments

Comments
 (0)