Skip to content
This repository has been archived by the owner on Jan 18, 2024. It is now read-only.

Latest commit

 

History

History
98 lines (63 loc) · 3.05 KB

File metadata and controls

98 lines (63 loc) · 3.05 KB

NodeJS with Selenium/Mocha/Chai Examples

These examples show how to run the rulesets using a Selenium/Mocha/Chai framework:

  • selenium-webdriver
  • mocha
  • chai

Prerequisites

See the prerequisites.

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/nodejs

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 dependencies, run the following command from the examples/nodejs directory:

npm install

Step 2: Invoke the Ruleset Runners

Custom Ruleset

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

npm run custom.ruleset.runner

The output should match the Custom Ruleset Runner Output.

aXe Ruleset

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

npm run aXe.ruleset.runner

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:

var url = "http://www.google.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.

Include in Your Project

These steps show how to use the published NPM module in your project.

  1. Install accessibility-ruleset-runner to bring in the javascript files for the custom/axe rulesets.
npm install @ebay/accessibility-ruleset-runner --save-dev

Note: You may modify the version by editing the package.json file.

  1. Edit the custom.ruleset.runner.js and axe.ruleset.runner.js to point to the installed custom.ruleset.X.X.X.js and axe.ruleset.X.X.X.js javascript files (replace X's appropriately)
var customRuleset = fs.readFileSync('./node_modules/accessibility-ruleset-runner/rulesets/custom.ruleset.X.X.X.js','utf8');
var aXeRuleset = fs.readFileSync('./node_modules/accessibility-ruleset-runner/rulesets/aXe.ruleset.X.X.X.js','utf8');
  1. Copy the custom.ruleset.runner.js and axe.ruleset.runner.js into a folder within your project

  2. Configure the scripts section of the package.json to include the runner (replace src/XXX with the folder used in Step 3)

  "scripts": {
    ...
    "custom.ruleset.runner": "mocha src/XXX/custom.ruleset.runner.js",
    "aXe.ruleset.runner": "mocha src/XXX/aXe.ruleset.runner.js",
  },