-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
35 lines (29 loc) · 935 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
const AxeBuilder = require('axe-webdriverjs');
const AxeReports = require('axe-reports');
const webdriver = require('selenium-webdriver');
const pages = require('./settings/pages.json');
const config = require('./settings/config.json');
const driver = new webdriver.Builder().forBrowser(config.browser).build();
const axeBuilder = AxeBuilder(driver).withTags(config.tags);
const WAIT_UNTIL_MS = 1000;
function generateReport () {
return pages.forEach(generatePageReport);
}
function generatePageReport (page) {
driver.get(page.url);
return driver
.wait(webdriver.until.titleIs(page.title), WAIT_UNTIL_MS)
.then(exportReport(page.name));
}
function exportReport (filename) {
axeBuilder.analyze((results) => {
return Promise.resolve(AxeReports.processResults(
results,
config.format,
`${config.path}/${filename}`,
config.create
));
});
}
generateReport();
driver.quit();