Skip to content

Instantly share code, notes, and snippets.

@acip
Last active November 26, 2020 13:50
Show Gist options
  • Save acip/f1ece6e965cbb601a7f9345a0f8ad083 to your computer and use it in GitHub Desktop.
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.
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