Skip to content
Learn with RV – Tech Blog
Learn with RV – Tech Blog

#testautomation #qa #programming #linux #devops

  • Home
  • Who am I?
  • 1-on-1 Mentoring
  • Test Automation Incubator
  • 24 Testimonials
  • YouTube
  • LinkedIn
  • Contact
Learn with RV – Tech Blog

#testautomation #qa #programming #linux #devops

pa11y-logo
September 4, 2024October 2, 2024

Web Accessibility: A step-by-step guide to Testing with pa11y

Accessibility enhances the user experience for everyone, allowing a wider audience to engage with your content. One powerful tool that can help you in this process is Pa11y—a robust, open-source accessibility testing tool that streamlines the identification and resolution of accessibility issues.

In this step-by-step tutorial, I will guide you through the process of setting up and using Pa11y to audit your website’s accessibility. This guide will provide you with the knowledge and tools to make your website more inclusive.

Prerequisites

NodeJS v18 or above

Getting started with pa11y

Pa11y is a command-line interface which loads web pages and highlights any accessibility issues it finds.

Useful for when you want to run a one-off test against a web page.

Installation

pa11y is an npm package, therefore you can simply install it globally on your computer by running in the CLI the following command:

npm install -g pa11y

Testing with pa11y

Find accessibility issues at an URL, running from CLI:

 pa11y https://razvanvancea.ro/

Runners: HTML_CodeSniffer vs. axe

Pa11y’s default runner is HTML_CodeSniffer but axe is also supported

Running pa11y with axe:

pa11y https://razvanvancea.ro/ --runner axe

Results

pa11yresults

How to display only critical errors

  • notice – general message, not necessarily something wrong but to be aware of concerning a particular elemen
  • warning – something that we should take a look at it, but not necessarily an error
  • error – crucial issue that should be fixed
pa11y https://razvanvancea.ro/ --ignore "warning;notice"

How to hide elements

This approach is used to exclude specific elements from testing (e.g. elements that are visual or screen-reader only)

pa11y https://razvanvancea.ro/ --hide-elements "h1.home__title"

How to set thresholds

These represents the maximum number of accepted errors in order for the test to ‘pass’ or ‘fail’

pa11y https://razvanvancea.ro/ --threshold 5

How to set specific standard (e.g. WCAG2AAA)

Note: if you don’t specify any, WCAG2AA will be used by default

pa11y --standard WCAG2AAA https://razvanvancea.ro/

 

Test results in a HTML format

pa11y --reporter html https://razvanvancea.ro/ > results.html


 Example

a11y-html-report

 

Test results in a JSON format

pa11y --reporter json https://razvanvancea.ro/ > results.json

Test results in a CSV format

pa11y --reporter csv https://razvanvancea.ro/ > results.csv

 

Enjoyed this article? Make sure to subscribe to my YouTube Channel for more Test Automation tutorials, and follow me on LinkedIn and Twitter for regular insights.
Looking to improve your test automation skills?
I’ve created a personalized 1-on-1 Mentoring program refined to boost YOUR skills. Reach out at iamrv@razvanvancea.ro for more details and together will create a learning path adapted to your current skills and goals that you are aiming for, in a timely-efficient manner🚀

Post Views: 556

Related

Share this article:
Tools

Post navigation

Previous post
Next post

Comment

  1. Paul says:
    September 18, 2024 at 7:37 am

    I recommend DoesQA if anyone wants to integrate Pa11y into their functional tests. You might need to run the checks on logged-in pages or want accessibility audits after CI/CD or scheduled.

Comments are closed.

Recent Posts

  • NodeJS v20 added native support for reading environment variables
  • ‘selectors’ vs. ‘locators’ – what is the difference?
  • Internationalization (i18n) – in test automation
  • Appium v3 is here: essential changes
  • Zen Browser review: The calmer side of internet

Recent Comments

  1. Paul on Web Accessibility: A step-by-step guide to Testing with pa11y
  2. Automated Tests for website Accessibility with Axe and TestCafe - Learn with RV - Tech Blog on How to generate E2E TestCafe Framework in seconds
  3. RV on Exploring Faker.js: A Powerful Tool for Generating Realistic Random Test Data
  4. Adrian Maciuc on Exploring Faker.js: A Powerful Tool for Generating Realistic Random Test Data
  5. Nick on Cypress vs Playwright vs Testcafe – which framework is faster?

Archives

  • November 2025
  • October 2025
  • September 2025
  • August 2025
  • July 2025
  • June 2025
  • March 2025
  • February 2025
  • January 2025
  • November 2024
  • October 2024
  • September 2024
  • August 2024
  • July 2024
  • May 2024
  • April 2024
  • March 2024
  • February 2024
  • January 2024
  • December 2023
  • October 2023
  • September 2023
  • August 2023
  • July 2023
  • June 2023
  • May 2023
  • April 2023

Categories

  • Linux
  • Programming
  • QA
  • Tools
  • Uncategorized
©2025 Learn with RV – Tech Blog | WordPress Theme by SuperbThemes