Automated Accessibility Testing Tool
npm install aattsh
$ git clone https://github.com/paypal/AATT.git
$ cd AATT
$ npm i
$ DEBUG=AATT* http_port=3000 node app.js . (If you want to run in Debug mode printing logs)
`
$sudo node app.js will run in default port 80 without printing log information
You can now access the running instance of AATT from http://localhost:3000
Integration with AATT API
AATT provides an API for evaluating HTML Source code from other servers. The API EndPoint is: https://your_nodejs_server/evaluate
* Accepts the following OPTIONAL parameters:
1. "source" to send the HTML source of the page. Can be a whole page or partial page source. Defaults to document
2. "engine" E.g. engine=htmlcs. This is the engine which will scan the code. It accepts a single value of "axe", chrome" or "htmlcs". Defaults to axe
3. "ouput" to get the jsonified string. E.g. output=json. If this parameter is not set or left empty, it will return a string with table data that can be parsed or appended directly into your page. Defaults to json.
4. "errLevel" Error level like Error, Warning or Notices . Mapped to 1, 2 and 3 respectively. E.g. "1,2,3" . (For HTMLCS engine)
5. "level" This option applies only for the default htmlcs evaluation engine. Options can be either of the following WCAG2AA, WCAG2A, WCAG2AAA, Section508 . Defaults to "WCAG2A" (For HTMLCS engine)
* Set the Request Header Content-type as application/x-www-form-urlencoded
Example
Here is a sample ajax script which would initiate the request:
` html
var xmlhttp = new XMLHttpRequest();
xmlhttp.open("POST","http://your_nodejs_server/evaluate",true);
xmlhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
xmlhttp.send("source=" + document.getElementById('source').value + "&priority=" + document.getElementById('priority').value);
`
How to Use with nemo-accessibility as a plugin
Nemo is a node.js based automation framework for browser automation. It's plugin-architecture helps switch on/off different capabilities. The nemo-accessibility plugin performs accessibility scanning while running browser automation using Nemo framework.
Learn more about nemo
nemo-accessibility plugin uses the AATT accessibility API to evaluate HTML source. Therefore you must specify the API url under as a plugin argument like below.
`json
"nemo-accessibility":{
"module":"nemo-accessibility",
"arguments": ["https://your_nodejs_accessibility_server/evaluate"]
}
`
How to Use with nightwatchJS
Nightwatch JS is another UI automated testing framework powered by Node.js and uses the Selenium WebDriver API. To call AATT, you need to use the request module. NightwatchJs has call back functions like before and after hooks that would be called before or after executing a test case. Request to AATT API should be done in after hook passing the source code of the page to the API. Here is an example commit on how to do this with Nightwatch.
How to use as a node module
The AATT evaluate function can be used directly as a node module, without the
need for using a web API.
$3
Add the module to your project
`sh
npm install --save aatt
`
$3
This takes the same options as the web /evaluate HTTP endpoint.
`javascript
const { evaluate } = require('aatt');
evaluate({
source: "Foo Bar
",
output: "json",
engine: "htmlcs",
level: "WCAG2A"
}).then(result => {
console.log('Results', JSON.parse(result));
});
``