TL;DR: Accessibility is a crucial aspect of web development that ensures everyone, regardless of their abilities, can access and use your website. Web Content Accessibility Guidelines (WCAG) provide a standard for web accessibility, and adhering to them is not only ethically important but also increasingly becoming a legal requirement.
One valuable tool for checking WCAG compliance is Google Lighthouse. It can help identify accessibility issues during development. And when integrated into your test automation project with tools like Neodymium, it can significantly streamline your accessibility testing and monitoring process.
What is WCAG and Why is it Important?
WCAG, or Web Content Accessibility Guidelines, are a set of standards developed to make web content more accessible to people with disabilities. These guidelines cover a wide range of disabilities, including visual, auditory, motor, and cognitive impairments. By following WCAG, you ensure that your website is usable by a larger audience. Approximately 15% of the world’s population has some form of disability.
WCAG compliance is also gaining traction legally, with governments in the US and EU enforcing accessibility standards. Non-compliance can lead to lawsuits and of course to less revenue and visitors.
The Role of Test Automation
Automating WCAG checks using tools like Lighthouse can help find and fix accessibility flaws early in the development cycle, saving time and resources. It also reduces the burden on manual testers by automatically generating accessibility reports.
Most importantly, test automation maintains the achieved level of accessibility of the application through regression testing.
If you have an existing or planned test automation project, it is crucial to incorporate WCAG compliance into your testing strategy. This is why we have integrated Lighthouse into Neodymium, allowing you to easily extend your test cases with accessibility checks.
How to Use Lighthouse with Neodymium
Here’s a simplified example of how to integrate Lighthouse with Neodymium:
- Prerequisites: Ensure you have Neodymium set up and Lighthouse CLI installed. Lighthouse only works with Chrome or Chromium-based browsers.
- Triggering Lighthouse: Neodymium provides the
LighthouseUtils.createLightHouseReport(name)
method. Call this method at the desired point in your test to generate a Lighthouse report. - Analyzing Results: After the test run, the Lighthouse report will be attached to the final test report (e.g., Allure report).
1 2 3 4 5 6 |
@NeodymiumTest public void testHomepage() throws Exception { var homePage = OpenHomePageFlow.flow(); LighthouseUtils.createLightHouseReport("Homepage"); } |

Important: Creating a report requires Lighthouse to refresh the current web page. That approach doesn’t work with some types of pages or states.
Lighthouse Validation
Neodymium allows you to validate Lighthouse scores and specific audits programmatically.
Scores
Lighthouse provides scores for Performance, Accessibility, Best Practices, and SEO. You can set thresholds in Neodymium to automatically fail tests if these scores fall below a certain value.
To properly verify those scores, we implemented configuration properties in the neodymium.properties file.
1 2 3 4 |
neodymium.lighthouse.assert.thresholdScore.performance = 0.5 neodymium.lighthouse.assert.thresholdScore.accessibility = 0.5 neodymium.lighthouse.assert.thresholdScore.bestPractices = 0.5 neodymium.lighthouse.assert.thresholdScore.seo = 0.5 |
Audits
You can also validate specific Lighthouse audits. For example:
1 |
neodymium.lighthouse.assert.audits = aria-roles aria-text |
This property is used to identify which audit IDs should be evaluated. The example checks for errors in the Lighthouse audits for aria-roles
and aria-text
. If either or both of these audits find an error, an exception will be thrown. For a complete list of existing audit IDs and their corresponding titles, please refer to our documentation.
Limitations of Automated Accessibility Testing
While automated tools like Lighthouse are incredibly helpful, they can’t catch all accessibility issues. Some aspects, like the meaningfulness of alt text or the logical flow of keyboard navigation, still require human judgment.
It’s important to note that it is possible to build an inaccessible website that still gets a high Lighthouse score. Automated tools provide a good starting point, but they should be complemented by manual testing and user testing with people with disabilities.
Conclusion
Integrating Google Lighthouse with Neodymium into your test automation project is a great way to improve your website’s accessibility. It helps catch issues early, automates report generation, and enables validation of accessibility scores and audits. While not a complete solution, it is a powerful tool in making the web more accessible to everyone.
More information on how to integrate Lighthouse in Neodymium are available at https://github.com/Xceptance/neodymium/wiki/Accessibility