TestNG
Use this guide when your Selenium web tests run with TestNG and you want Accessibility Automation in the same sessions. The runner does not change how Accessibility works on the grid: you still enable it with capabilities, then either use on-demand hooks or auto-scan. Details match the main Selenium Accessibility Automation doc; this page adds a TestNG-shaped onboarding path.
Browsers: Accessibility Automation is supported on Chrome and Edge (recent versions). Set
browserNameaccordingly.
Prerequisites
- TestMu AI username and access key (environment variables)
- A Selenium + TestNG project already hitting the TestMu AI grid (hub URL and capabilities)
- Accessibility entitlement for your organization
- Access to the Automation dashboard and the Accessibility tab for the session build
Onboarding path (first successful run)
1. Confirm your TestNG entry point
Most teams initialize the driver in a Base test class (@BeforeMethod / @BeforeClass) or a small factory. You only need one place where DesiredCapabilities or MutableCapabilities is built so every test method gets Accessibility enabled.
2. Add Accessibility capabilities
Enable Accessibility and optional WCAG / best-practice flags (full reference: Configure Accessibility Automation).
Minimal enable:
capabilities.setCapability("accessibility", true);
Optional tuning (example):
capabilities.setCapability("accessibility", true);
capabilities.setCapability("accessibility.wcagVersion", "wcag21aa");
capabilities.setCapability("accessibility.bestPractice", false);
capabilities.setCapability("accessibility.needsReview", true);
3. Choose scan mode
A. On-demand (recommended for most suites)
After navigation and when the page is stable, call:
driver.executeScript("lambda-accessibility-scan");
If you enable accessibility but never call this hook (and do not use auto-scan), no Accessibility report is produced for that navigation.
B. Continuous auto-scan
Scan on every navigation without hooks:
capabilities.setCapability("accessibility", true);
capabilities.setCapability("accessibility.autoscan", true);
4. Wire TestNG suite XML (optional but typical)
Point your testng.xml (or Gradle/Maven TestNG config) at the packages or classes that use the shared base class so every included test inherits the same driver setup. Run a single @Test first to validate capabilities before scaling the suite.
5. Execute and open the report
mvn test
(or your TestNG CLI / IDE run configuration.)
Then open the Automation Dashboard, select the session, and use the Accessibility tab for the generated report (same flow as the Selenium guide).
What gets reported
Reports use the standard Accessibility automation pipeline: issues, severity, WCAG mapping, and the same dashboard views as other Selenium-based runs.
Troubleshooting
| Symptom | What to check |
|---|---|
| No Accessibility tab / empty report | Confirm accessibility: true and that you either call lambda-accessibility-scan or set accessibility.autoscan. |
| Wrong WCAG level | Adjust accessibility.wcagVersion in settings reference. |
| Flaky scans | Prefer hooks after explicit waits rather than autoscan on heavy SPAs. |
Related docs
- Selenium
- Configure Accessibility Automation
- JUnit 5 (same model, different runner)
- CI/CD Integration Guide
