• This repository has been archived on 19/Mar/2021
  • Stars
    star
    430
  • Rank 101,083 (Top 2 %)
  • Language
    JavaScript
  • License
    Mozilla Public Li...
  • Created about 8 years ago
  • Updated over 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

[Deprecated] A command-line interface for the aXe accessibility testing engine

[DEPRECATED] axe-cli

No Maintenance Intended

This repository has been deprecated. The package has been moved to axe-core-npm. The package will be available via NPM as @axe-core/cli.


Greenkeeper badge

Join the chat at https://gitter.im/dequelabs/axe-core Version License

Provides a command line interface for aXe to run quick accessibility tests.

Getting Started

Install Node.js if you haven't already. This project requires Node 6+. By default, axe-cli runs Chrome in headless mode, which requires Chrome 59 or up.

Install axe-cli globally: npm install axe-cli -g

Lastly, install the webdrivers of the browsers you wish to use. A webdriver is a driver for your web browsers. It allows other programs on your machine to open a browser and operate it. Current information about available webdrivers can be found at selenium-webdriver project. Alternatively, you could use Webdriver manager

Usage

After installing, you can now run the axe command in your CLI, followed by the URL of the page you wish to test:

axe https://www.deque.com

You can run multiple pages at once, simply add more URLs to the command. Keep in mind that axe-cli is not a crawler, so if you find yourself testing dozens of pages at once, you may want to consider switching over to something like axe-webdriverjs. If you do not specify the protocol, http will be used by default:

axe www.deque.com, dequeuniversity.com

Note: If you are having difficulty with the color scheme, use --no-color to disable text styles.

Running specific rules

You can use the --rules flag to set which rules you wish to run, or you can use --tags to tell axe to run all rules that have that specific tag. For example:

axe www.deque.com --rules color-contrast,html-has-lang

Or, to run all wcag2a rules:

axe www.deque.com --tags wcag2a

In case you want to disable some rules, you can use --disable followed by a list of rules. These will be skipped when analyzing the site:

axe www.deque.com --disable color-contrast

This option can be combined with either --tags or --rules.

A list of rules and what tags they have is available at: https://dequeuniversity.com/rules/worldspace/3.0/.

Saving the results

Results can be saved as JSON data, using the --save and --dir flags. By passing a filename to --save you indicate how the file should be called. If no filename is passed, a default will be used. For example:

axe www.deque.com --save deque-site.json

Or:

axe www.deque.com --dir ./axe-results/

Sending results to STDOUT

To output the test results to STDOUT, provide the --stdout flag. This flag has the side-effect of silencing all other logs/output (other than errors, which are written to STDERR).

To print the entire result object to your terminal, do:

axe --stdout www.deque.com

To pipe the results to a file, do:

axe --stdout www.deque.com > your_file.json

To pipe the results to a JSON-parsing program for further processing, do:

axe --stdout www.deque.com | jq ".[0].violations"

Defining the scope of a test

If you want to only test a specific area of a page, or wish to exclude some part of a page you can do so using the --include and --exclude flags and pass it a CSS selector:

axe www.deque.com --include "#main" --exclude "#aside"

You may pass multiple selectors with a comma-delimited string. For example:

axe www.deque.com --include "#div1,#div2,#div3"

Custom axe-core versions

Axe-cli will look for locally available versions of axe-core. If the directory from where you start axe-cli has an axe.js file, or has a node_modules directory with axe-core installed in it. Axe-cli will use this version of axe-core instead of the default version installed globally.

To specify the exact file axe-core file axe-cli should use, you can use the --axe-source flag (-a for short), with a relative or absolute path to the file.

axe www.deque.com --axe-source ./axe.nl.js

Different browsers

Axe-cli can run in a variety of web browsers. By default axe-cli uses Chrome in headless mode. But axe-cli is equally capable of testing pages using other web browsers. Running in another browser requires that browser's webdriver to be available on your PATH. You can find a list of available webdrivers and how to install them at: https://seleniumhq.github.io/docs/wd.html

To run axe-cli using another browser, pass it in as the --browser option:

axe www.deque.com --browser chrome

Or for short:

axe www.deque.com -b c

Custom Chrome Flags

When using the Headless Chrome browser, you may provide any number of flags to configure how the browser functions.

Options are passed by name, without their leading -- prefix. For example, to provide the --no-sandbox --disable-setuid-sandbox --disable-dev-shm-usage flags to the Chrome binary, you'd do:

axe --chrome-options="no-sandbox,disable-setuid-sandbox,disable-dev-shm-usage" www.deque.com

CI integration

Axe-cli can be ran within the CI tooling for your project. Many tools are automatically configured to halt/fail builds when a process exits with a code of 1.

Use the --exit flag, -q for short, to have the axe-cli process exit with a failure code 1 when any rule fails to pass.

axe www.deque.com --exit

Timing and timeout

For debugging and managing timeouts, there are two options available. With --timer set, axe-cli will log how long it takes to load the page, and how long it takes to run axe-core. If you find the execution of axe-core takes too long, which can happen on very large pages, use --timeout to increase the time axe has to test that page:

axe www.cnn.com --timeout=120

Delay audit to ensure page is loaded

If you find your page is not ready after axe has determined it has loaded, you can use --load-delay followed by a number in milliseconds. This will make axe wait that time before running the audit after the page has loaded.

axe www.deque.com --load-delay=2000

Verbose output

To see additional information like test tool name, version and environment details, use the --verbose flag, -v for short.

axe www.deque.com --verbose

ChromeDriver Path

If you need to test your page using an older version of Chrome, you can use --chromedriver-path followed by the absolute path to the desired version of the ChromeDriver executable.

axe www.deque.com --chromedriver-path="absolute/path/to/chromedriver"

More Repositories

1

axe-core

Accessibility engine for automated Web UI testing
JavaScript
5,844
star
2

react-axe

[DEPRECATED] Accessibility auditing for React.js applications
TypeScript
1,156
star
3

axe-core-npm

JavaScript
591
star
4

axe-webdriverjs

Provides a chainable axe API for Selenium's WebDriverJS and automatically injects into all frames.
JavaScript
130
star
5

pattern-library

Deque pattern library
JavaScript
116
star
6

cauldron

TypeScript
90
star
7

axe-core-gems

Ruby integration for axe-core, the accessibility testing engine
Ruby
84
star
8

axe-core-maven-html

Tools for using axe for web accessibility testing with JUnit, Selenium, and Playwright
Java
81
star
9

agnostic-axe

Framework agnostic accessibility reporter, powered by axe-core
JavaScript
80
star
10

ngA11y

Angular accessibility modules
JavaScript
74
star
11

axe-android

WCAG Accessibility compliance library for Android Applications.
Java
65
star
12

axe-puppeteer

[DEPRECATED] Provides a chainable axe API for Puppeteer and automatically injects into all frames.
TypeScript
59
star
13

combobo

Accessible combobox
JavaScript
48
star
14

Deque-University-for-iOS

Accessibility demos and best practices for the iOS platform. Need iOS Accessibility help? Ask us a question by adding an Issue to this repository! Help us build a community of iOS Accessibility experts.
HTML
37
star
15

color-palette

Color Palette Color Contrast Analyzer
JavaScript
35
star
16

workshop

Workshop
JavaScript
27
star
17

Deque-University-for-Android

All you need to improve the Accessibility of your Android Applications in one place! Build the application to see Accessible Examples, check out Attest for debugging tools, or post an Issue to leverage our community of Android Accessibility experts.
Java
27
star
18

puppeteer-devtools

Extended puppeteer methods for getting extension devtools contexts
TypeScript
18
star
19

smashing-workshop

JavaScript
18
star
20

axe-firefox-devtools

Integration of axe-core into the Firefox developer tools
17
star
21

axe-core-nuget

Axe Core integration for C# .NET
C#
17
star
22

foreign-keycloak-wrapper

PGXN PostgreSQL foreign data wrapper for keycloak's REST API
Python
16
star
23

axe-selenium-java

Tools for using aXe for web accessibility testing with JUnit and Selenium.
Java
14
star
24

cauldron-react

TypeScript
14
star
25

grunt-axe-webdriver

JavaScript
12
star
26

axe-rules

The Accessibility Rules for automated testing of HTML-based user interfaces.
12
star
27

axe-selector

TypeScript
10
star
28

axe-matchers

[DEPRECATED] Ruby integration for aXe-core, the accessibility testing engine
Ruby
9
star
29

csun20-aria-menu-button

JavaScript
9
star
30

axrl

Accessibility Reporting Language
JavaScript
9
star
31

corro

A powerful, extensible validation framework for node.js.
JavaScript
8
star
32

axe-linter-action

A GitHub Action to lint for any accessibility issues in your pull requests.
Shell
7
star
33

get-it-right-the-first-time

TypeScript
6
star
34

axe-devtools-android-sample-app

Kotlin
6
star
35

axe-devtools-ios-sample-app

Swift
5
star
36

axe-reporter-earl

[DEPRECATED] A reporter for axe-core.
TypeScript
5
star
37

csun19-tdd-component

Live coding at csun 2019!
JavaScript
5
star
38

action-sync-branches

Creates a sync pull request between two branches
TypeScript
5
star
39

axe

Package for marketing all of our open source projects
4
star
40

axe-devtools-html-api-examples

Library of example projects for axe DevTools HTML api integrations
JavaScript
4
star
41

react-wai-accordion

TypeScript
4
star
42

axe-devtools-ios

Start testing for accessibility in your iOS application today with axe DevTools for iOS. Please refer to the README to get started.
Objective-C
3
star
43

a11y-in-design-and-development

Smashing workshop | Day II | October 4th, 2022
JavaScript
2
star
44

axe-website

Website for axe-core
JavaScript
2
star
45

eslint-config-deque

Our extensible ESLint configuration
JavaScript
2
star
46

monitor-utility

Previously the "Comply custom reporter" from Devservices, now useful for any customer. Allows customers to login via the CLI and fetch detailed data from their Monitor projects.
JavaScript
2
star
47

semantic-pr-title

A GitHub Action to validate pr titles against Conventional Commits
TypeScript
2
star
48

watcher-examples

TypeScript
2
star
49

act-reports-axe

ACT reports for axe-core and axe DevTools
TypeScript
1
star
50

hr-a11y-workshop

JavaScript
1
star
51

element-matches

Element#matches un-prefixer
JavaScript
1
star
52

Form-Personalization

A simple chrome browser extension to support personalization of input forms utilizing the auto complete attribute.
JavaScript
1
star
53

attest-release-scripts

Shell
1
star
54

axe-test-fixtures

Fixtures for testing integrations of axe-core
JavaScript
1
star
55

axe-act-testrunner

Axe-core testrunner using the ACT test case format
JavaScript
1
star
56

iOS-Increase-Contrast

Swift
1
star
57

a11y-metrics-poc

A POC for Deque A11Y Metrics
1
star
58

axeDevToolsMobileTools

Mobile tools to demonstrate REST API's from python
Python
1
star
59

workshop-08-2024

design/dev workshop August 2024
HTML
1
star
60

action-twistlock

A GitHub action for scanning a Docker image with Twistlock
JavaScript
1
star