Last active
November 26, 2020 13:50
-
-
Save acip/f1ece6e965cbb601a7f9345a0f8ad083 to your computer and use it in GitHub Desktop.
Run an accessibility test and generate report with Puppeteer and Accessibility Developer Tools - https://github.com/GoogleChrome/accessibility-developer-tools.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const puppeteer = require('puppeteer'); | |
const fs = require('fs'); | |
(async () => { | |
const browser = await puppeteer.launch({ | |
userDataDir: './myUserDataDir', | |
dumpio: true, | |
}); | |
const page = await browser.newPage(); | |
await page.goto('https://google.com'); | |
// download it from here: https://raw.github.com/GoogleChrome/accessibility-developer-tools/stable/dist/js/axs_testing.js | |
await page.evaluate(fs.readFileSync('./axs_testing.js', 'utf8')); | |
const audit = await page.evaluate(() => { | |
const results = window.axs.Audit.run(); | |
return window.axs.Audit.createReport(results); | |
}); | |
console.log(audit); | |
await browser.close(); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment