Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
109 lines (66 sloc) 4.32 KB

Python with Selenium Examples

These examples show how to run the rulesets using Selenium Webdriver.

Prerequisites

We assume the following are installed:

Verify Prerequisites

To check if ChromeDriver and Python 2.7.16 have already been installed, type the appropriate commands to print the version.

$ 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).

ChromeDriver

Selenium is a tool that automates browsers and ChromeDriver is the Chrome implementation of WebDriver, which is an open source tool for automated testing of webapps across many browsers.

See Chrome Driver Help for more information about installation.

Python 2.7.16

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.

pip is the package installer for Python. pip comes preinstalled for Python versions above Python 2.7.9. If you need to install pip manually, you may visit the pip installation page.

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:

pip freeze

Step 2: Invoke the Ruleset Runners

Custom Ruleset

To run the Custom Ruleset, run the following command from the examples/python directory:

python custom.ruleset.runner.py

The output should match the Custom Ruleset Runner Output.

aXe Ruleset

To run the aXe Ruleset, run the following command from the examples/python directory:

python aXe.ruleset.runner.py

The output should match the aXe Ruleset Runner Output.

Modifications

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:

driver.get("https://www.ebay.com")

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.

You can’t perform that action at this time.