Python with Selenium Examples
These examples show how to run the rulesets using Selenium Webdriver.
We assume the following are installed:
$ chromedriver --version ChromeDriver 2.40.565498 (ea082db3280dd6843ebfb08a625e3eb905c4f5ab) $ python --version Python 2.7.16 $ pip --version pip 18.1 from c:\python27\lib\site-packages\pip (python 2.7)
Note: Python 2.7 is required but other than that, versions may vary.
If the prerequisite has not been installed, first use the information below to install, then run the appropriate commands to print the version (ie verify the installation by running the commands above).
See Chrome Driver Help for more information about installation.
Python is an interpreted high-level programming language. Its built in data structures and dynamic typing make it attractive for rapid development and scripting. Visit the Python 2.7.16 Release for various installers.
Note: Windows users are recommended to use the Git Bash console to run Node.js. An Installer may be found on the Git Downloads.
Note: Windows users may need to add the location of Python (ie C:\Python27) to the Path environment variable.
Note: Windows users may need to add the location of pip (ie C:\Python27\Scripts) to the Path environment variable.
Running Rulesets Against a Website
Step 0: Download Code and Change the Directory
Run the following commands:
git clone https://github.com/eBay/accessibility-ruleset-runner/ cd accessibility-ruleset-runner/examples/python
Note: If you are working from a forked repository, you might use slightly different commands than those given above. Also, if you have already downloaded the code, you can skip step.
Step 1: Install Package Dependencies
To install the selenium dependency, run the following command from the examples/python directory:
pip install selenium
To verify selenium (ie version 3.141.0) and urllib3 (ie version 1.25.3) were installed successfully, run the following command from the examples/python directory:
Step 2: Invoke the Ruleset Runners
To run the Custom Ruleset, run the following command from the examples/python directory:
The output should match the Custom Ruleset Runner Output.
To run the aXe Ruleset, run the following command from the examples/python directory:
The output should match the aXe Ruleset Runner Output.
Test Another Website
The examples are setup to be run without any configuration necessary. However, users can test a different url by modifying the following line:
In addition, sometimes users need to sign in, load urls, click buttons, etc before testing a view. Consider making the appopriate modifications necessary for your use case.