- install playwright
npm i -g playwright
. - install scriptwriter
npm i -g scriptwriter
. - create a folder to run scriptwriter from and to load and save files.
- install axe-core
npm -i axe-core
. You can load theaxe-core.command.json
file to show you how to build your own commands. - start scriptwriter
scriptwriter
. You can load into-b firefox
or-b webkit
. - copy the
axe.command.js
file to your folder and.load axe.command
or paste it right into the repl. - next, navigate to a site using
page.goto
or if you usedscriptwriter --no-headless
you can browse. - run axe on that page
.axe
Last active
March 31, 2020 10:53
-
-
Save AutoSponge/d0a0acbb02b2c8bd003af5ac7b4f4a64 to your computer and use it in GitHub Desktop.
axe-core custom command for scriptwriter and accompanying Code Tour file.
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
// install axe-core locally | |
scriptwriter.completion = '.axe'; | |
director.defineCommand('axe', { | |
help: 'run axe-core against the current page', | |
async action(configFile) { | |
const { readFile } = fs.promises; | |
const axe = await readFile('./node_modules/axe-core/axe.min.js', 'utf8'); | |
const config = configFile ? require(path.resolve(configFile)) : {}; | |
const expression = `${axe} | |
;(async (config) => { | |
Object.assign(config, {branding: {brand: 'scriptwriter'}}); | |
axe.configure(config); | |
const results = await axe.run() | |
const {incomplete, inapplicable, passes, ...rest} = results; | |
return {...rest}; | |
})(${JSON.stringify(config)});`; | |
const response = await page.evaluate(expression); | |
console.log(util.inspect(response, {depth: Infinity, colors: true})); | |
director.displayPrompt(); | |
}, | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment