
Security News
How Enterprise Security Is Adapting to AI-Accelerated Threats
Socket CTO Ahmad Nassri discusses why supply chain attacks now target developer machines and what AI means for the future of enterprise security.
@axe-core/webdriverio
Advanced tools
Provides a chainable axe API for WebdriverIO and automatically injects into all frames.
Support for @wdio/sync is deprecated and testing for it will be removed in a future release.
We're aware of an issue that occurs when using WebdriverIO v9 and the WebDriver Bidi protocol. We're investigating this issue and plan to update the community more thoroughly in early 2025.
If you are encountering this issue and wish to share your experience please add to the GitHub issue.
Install Node.js if you haven't already.
Download and install any necessary browser drivers on your machine's PATH. More on WebdriverIO setup.
To install the latest version of Chromedriver globally, install browser-driver-manager: npm install -g browser-driver-manager. Then run npx browser-driver-manager install chrome.
Install WebdriverIO: npm install webdriverio
Install @axe-core/webdriverio: npm install @axe-core/webdriverio
This module uses a chainable API to assist in injecting, configuring, and analyzing axe with WebdriverIO. As such, it is required to pass an instance of WebdriverIO.
Here is an example of a script that will drive WebdriverIO to a page, perform an analysis, and then log results to the console.
const { AxeBuilder } = require('@axe-core/webdriverio');
const { remote } = require('webdriverio');
(async () => {
const client = await remote({
logLevel: 'error',
capabilities: {
browserName: 'chrome',
'goog:chromeOptions': {
args: ['headless', 'disable-gpu']
}
}
});
await client.url('https://dequeuniversity.com/demo/mars/');
try {
const results = await new AxeBuilder({ client }).analyze();
console.log(results);
} catch (e) {
// do something with the error
}
client.deleteSession();
})();
Performs analysis and passes any encountered error and/or the result object.
new AxeBuilder({ client }).analyze((err, results) => {
if (err) {
// Do something with error
}
console.log(results);
});
new AxeBuilder({ client })
.analyze()
.then(results => {
console.log(results);
})
.catch(e => {
// Do something with error
});
Constructor for the AxeBuilder helper. You must pass an instance of WebdriverIO as the first argument.
const builder = new AxeBuilder({ client });
Adds a CSS selector to the list of elements to include in analysis
new AxeBuilder({ client }).include('.results-panel');
Add a CSS selector to the list of elements to exclude from analysis
new AxeBuilder({ client }).exclude('.another-element');
Specifies options to be used by axe.run. Will override any other configured options. including calls to AxeBuilder#withRules() and AxeBuilder#withTags(). See axe-core API documentation for information on its structure.
new AxeBuilder({ client }).options({ checks: { 'valid-lang': ['orcish'] } });
Limits analysis to only those with the specified rule IDs. Accepts a String of a single rule ID or an Array of multiple rule IDs. Subsequent calls to AxeBuilder#options, AxeBuilder#withRules or AxeBuilder#withRules will override specified options.
new AxeBuilder({ client }).withRules('html-lang');
new AxeBuilder({ client }).withRules(['html-lang', 'image-alt']);
Limits analysis to only those with the specified rule IDs. Accepts a String of a single tag or an Array of multiple tags. Subsequent calls to AxeBuilder#options, AxeBuilder#withRules or AxeBuilder#withRules will override specified options.
new AxeBuilder({ client }).withTags('wcag2a');
new AxeBuilder({ client }).withTags(['wcag2a', 'wcag2aa']);
Skips verification of the rules provided. Accepts a String of a single rule ID or an Array of multiple rule IDs. Subsequent calls to AxeBuilder#options, AxeBuilder#disableRules will override specified options.
new AxeBuilder({ client }).disableRules('color-contrast');
Set the frame testing method to "legacy mode". In this mode, axe will not open a blank page in which to aggregate its results. This can be used in an environment where opening a blank page is causes issues.
With legacy mode turned on, axe will fall back to its test solution prior to the 4.3 release, but with cross-origin frame testing disabled. The frame-tested rule will report which frames were untested.
Important Use of .setLegacyMode() is a last resort. If you find there is no other solution, please report this as an issue.
const axe = new AxeBuilder({ client }).setLegacyMode();
const result = await axe.analyze();
axe.setLegacyMode(false); // Disables legacy mode
@axe-core/webdriverio is unable to support iframes in shadow DOM elements due to lack of shadow DOM support in webdriverio devtools protocol.
FAQs
Provides a method to inject and analyze web pages using axe
The npm package @axe-core/webdriverio receives a total of 40,404 weekly downloads. As such, @axe-core/webdriverio popularity was classified as popular.
We found that @axe-core/webdriverio demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 4 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Socket CTO Ahmad Nassri discusses why supply chain attacks now target developer machines and what AI means for the future of enterprise security.

Security News
Learn the essential steps every developer should take to stay secure on npm and reduce exposure to supply chain attacks.

Security News
Experts push back on new claims about AI-driven ransomware, warning that hype and sponsored research are distorting how the threat is understood.