Gathering detailed insights and metrics for @axe-core/playwright
Gathering detailed insights and metrics for @axe-core/playwright
Gathering detailed insights and metrics for @axe-core/playwright
Gathering detailed insights and metrics for @axe-core/playwright
npm install @axe-core/playwright
Typescript
Module System
Node Version
NPM Version
56.4
Supply Chain
98.7
Quality
96.6
Maintenance
100
Vulnerability
79.3
License
Total
23,752,479
Last Day
19,494
Last Week
434,352
Last Month
1,667,361
Last Year
16,225,662
619 Stars
597 Commits
68 Forks
13 Watching
76 Branches
35 Contributors
Updated on 03 Dec 2024
JavaScript (59.32%)
TypeScript (40.46%)
HTML (0.12%)
CSS (0.08%)
Shell (0.01%)
Cumulative downloads
Total Downloads
Last day
20.1%
19,494
Compared to previous day
Last week
16.8%
434,352
Compared to previous week
Last month
-2%
1,667,361
Compared to previous month
Last year
180.4%
16,225,662
Compared to previous year
1
1
Provides a chainable axe API for playwright and automatically injects into all frames
Install Node.js if you haven't already.
Install Playwright: npm install playwright
Install @axe-core/playwright: npm install @axe-core/playwright
This module uses a chainable API to assist in injecting, configuring, and analyzing axe with Playwright. As such, it is required to pass an instance of Playwright.
Here is an example of a script that will drive Playwright to a page, perform an analysis, and then log results to the console.
1const { AxeBuilder } = require('@axe-core/playwright'); 2const playwright = require('playwright'); 3 4(async () => { 5 const browser = await playwright.chromium.launch({ headless: true }); 6 const context = await browser.newContext(); 7 const page = await context.newPage(); 8 await page.goto('https://dequeuniversity.com/demo/mars/'); 9 10 try { 11 const results = await new AxeBuilder({ page }).analyze(); 12 console.log(results); 13 } catch (e) { 14 // do something with the error 15 } 16 17 await browser.close(); 18})();
Constructor for the AxeBuilder helper. You must pass an instance of Playwright as the first argument.
1const builder = new AxeBuilder({ page });
Performs analysis and passes any encountered error and/or the result object.
1new AxeBuilder({ page }) 2 .analyze() 3 .then(results => { 4 console.log(results); 5 }) 6 .catch(e => { 7 // Do something with error 8 });
Adds a CSS selector to the list of elements to include in analysis
1new AxeBuilder({ page }).include('.results-panel');
Method chaining is also available, add multiple CSS selectors to the list of elements to include in analysis
1new AxeBuilder({ page }) 2 .include('.selector-one') 3 .include('.selector-two') 4 .include('.selector-three');
Note: arrays with more than one index when passing multiple CSS selectors are not currently supported example: .include(['#foo', '#bar', '#baz'])
Add a CSS selector to the list of elements to exclude from analysis
1new AxeBuilder({ page }).exclude('.another-element');
Method chaining is also available, add multiple CSS selectors to the list of elements to exclude from analysis
1new AxeBuilder({ page }) 2 .exclude('.selector-one') 3 .exclude('.selector-two') 4 .exclude('.selector-three');
Note: arrays with more than one index when passing multiple CSS selectors are not currently supported example: .exclude(['#foo', '#bar', '#baz'])
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.
1new AxeBuilder({ page }).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.
1new AxeBuilder({ page }).withRules('html-lang');
1new AxeBuilder({ page }).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.
1new AxeBuilder({ page }).withTags('wcag2a');
1new AxeBuilder({ page }).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.
1new AxeBuilder({ page }).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.
1const axe = new AxeBuilder({ page }).setLegacyMode(); 2const result = await axe.analyze(); 3axe.setLegacyMode(false); // Disables legacy mode
No vulnerabilities found.
Reason
19 commit(s) and 1 issue activity found in the last 90 days -- score normalized to 10
Reason
security policy file detected
Details
Reason
no binaries found in the repo
Reason
all changesets reviewed
Reason
no dangerous workflow patterns detected
Reason
license file detected
Details
Reason
dependency not pinned by hash detected -- score normalized to 5
Details
Reason
8 existing vulnerabilities detected
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
project is not fuzzed
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2024-12-02
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More