Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@axe-core/playwright

Package Overview
Dependencies
Maintainers
4
Versions
380
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@axe-core/playwright

Provides a method to inject and analyze web pages using axe

  • 4.10.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
198K
decreased by-51.18%
Maintainers
4
Weekly downloads
 
Created

What is @axe-core/playwright?

@axe-core/playwright is an accessibility testing library that integrates with Playwright to automate accessibility checks. It leverages the axe-core engine to analyze web pages and identify accessibility issues, making it easier for developers to ensure their applications are accessible to all users.

What are @axe-core/playwright's main functionalities?

Basic Accessibility Scan

This feature allows you to perform a basic accessibility scan on a web page. The code sample demonstrates how to launch a browser, navigate to a page, inject the axe-core script, and run an accessibility check.

const { chromium } = require('playwright');
const { injectAxe, checkA11y } = require('@axe-core/playwright');

(async () => {
  const browser = await chromium.launch();
  const page = await browser.newPage();
  await page.goto('https://example.com');
  await injectAxe(page);
  const results = await checkA11y(page);
  console.log(results);
  await browser.close();
})();

Customizing Axe-core Options

This feature allows you to customize the axe-core options for the accessibility scan. The code sample shows how to specify which WCAG levels to check for during the scan.

const { chromium } = require('playwright');
const { injectAxe, checkA11y } = require('@axe-core/playwright');

(async () => {
  const browser = await chromium.launch();
  const page = await browser.newPage();
  await page.goto('https://example.com');
  await injectAxe(page);
  const options = { runOnly: { type: 'tag', values: ['wcag2a', 'wcag2aa'] } };
  const results = await checkA11y(page, null, options);
  console.log(results);
  await browser.close();
})();

Excluding Elements from Scan

This feature allows you to exclude specific elements from the accessibility scan. The code sample demonstrates how to exclude elements with a specific class from being checked.

const { chromium } = require('playwright');
const { injectAxe, checkA11y } = require('@axe-core/playwright');

(async () => {
  const browser = await chromium.launch();
  const page = await browser.newPage();
  await page.goto('https://example.com');
  await injectAxe(page);
  const exclude = ['.ignore-this-element'];
  const results = await checkA11y(page, null, null, exclude);
  console.log(results);
  await browser.close();
})();

Other packages similar to @axe-core/playwright

Keywords

FAQs

Package last updated on 11 Nov 2024

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc