Rule and Category Exclusion for Web Accessibility Automation
Rule and category exclusion lets you remove individual accessibility rules, or entire rule categories, from a web accessibility automation scan before it runs. Two capabilities control it, on Selenium and Playwright sessions, both on the TestMu AI cloud grid and on HyperExecute:
| Capability | Type | Effect |
|---|---|---|
accessibility.excludeRules | array of axe rule IDs, or a comma-separated string | Each named rule is removed from the effective rule set for the session |
accessibility.excludeRuleCategories | array of category slugs, or a comma-separated string | Every rule in each named category is removed from the effective rule set |
Both are optional and can be combined. An excluded rule never runs: it is absent from the findings and from the score, the report says which rules ran and why the rest did not, and that snapshot is stored with the test so any result can be reproduced later. A session that sets neither capability behaves exactly as before.
When to use this
Use exclusion when your team has a known, accepted deviation that should not fail every build, for example a design-system colour token whose contrast has been signed off, or a third-party widget you cannot change. Without exclusion the only options were to live with permanently failing builds, or to hide the finding in the report afterwards, which distorts the score and cannot be enforced in CI.
Exclusion is part of the scan configuration, so it is enforceable in CI and applies to every scan in the session, including scans triggered by accessibility.autoscan. To suppress a single finding after a scan has run, use Hide and Restore Issues instead.
This page covers automation capabilities. For the same controls in the DevTools extension and in scheduled scans, see Rule and Category Exclusion in DevTools and Scheduled Scans. For Appium mobile automation, see Rule and Category Exclusion for Mobile App Accessibility.
Prerequisites
- A Selenium or Playwright project running on the TestMu AI cloud grid or on HyperExecute, with accessibility enabled through
accessibility: true. See Configure Accessibility Automation. - Scans triggered with the
lambda-accessibility-scanhook, or automatically withaccessibility.autoscan.
Rule IDs
Web rule IDs are the standard axe-core rule IDs, passed as they are. Matching is case-insensitive. Examples:
| Rule | Rule ID |
|---|---|
| Elements must meet minimum colour contrast ratio thresholds | color-contrast |
| Images must have alternative text | image-alt |
| Form elements must have labels | label |
| Required ARIA attributes must be provided | aria-required-attr |
| Links must have discernible text | link-name |
| Links must be distinguishable without relying on colour | link-in-text-block |
You can copy a rule ID straight out of a report or from the axe-core rule descriptions. Rules that axe-core marks as deprecated are not part of the catalog, because they never run. The Web Rule Repository maps rules to their WCAG success criteria.
The five AI-powered rules that TestMu AI adds on top of axe have their own IDs: alt-descriptive, alt-decorative-hidden, image-in-text, html-title-descriptive and html-lang-matches-visible-language. AI rules do not run on automation sessions, so these IDs are dropped at validation if they are passed in accessibility.excludeRules. They can be switched off in DevTools and in scheduled scans.
Category slugs
Categories are axe-core's own rule categories, addressed by a lowercase, hyphenated slug. Every rule belongs to exactly one category. The web catalog has twelve:
| Category | Slug |
|---|---|
| ARIA | aria |
| Structure and Semantics | structure-and-semantics |
| Text Alternatives | text-alternatives |
| Keyboard | keyboard |
| Name Role Value | name-role-value |
| Tables | tables |
| Forms | forms |
| Language | language |
| Time and Media | time-and-media |
| Color Contrast | color-contrast |
| Sensory and Visual Cues | sensory-and-visual-cues |
| Parsing | parsing |
Matching is case-insensitive and tolerates spaces, so "Text Alternatives" is accepted as well as text-alternatives. How many rules a category removes from a given scan depends on the selected WCAG version and level and on the Best Practices toggle, because each of those narrows the set before any exclusion applies.
color-contrast is both a rule ID and a category slug. The capability you put it in decides what it means: in accessibility.excludeRules it removes the single contrast-ratio rule, in accessibility.excludeRuleCategories it removes every rule in the Color Contrast category.
Examples
Enable accessibility, target WCAG 2.1 AA, skip two specific rules, and skip the whole ARIA category.
"LT:Options": {
"accessibility": true,
"accessibility.wcagVersion": "wcag21aa",
"accessibility.bestPractice": true,
"accessibility.excludeRules": ["color-contrast", "image-alt"],
"accessibility.excludeRuleCategories": "aria"
}
capability.setCapability("accessibility", true);
capability.setCapability("accessibility.wcagVersion", "wcag21aa");
capability.setCapability("accessibility.bestPractice", true);
capability.setCapability("accessibility.excludeRules", Arrays.asList("color-contrast", "image-alt"));
capability.setCapability("accessibility.excludeRuleCategories", "aria");
capabilities = {
"accessibility": True,
"accessibility.wcagVersion": "wcag21aa",
"accessibility.bestPractice": True,
"accessibility.excludeRules": ["color-contrast", "image-alt"],
"accessibility.excludeRuleCategories": "aria",
}
const capabilities = {
"accessibility": true,
"accessibility.wcagVersion": "wcag21aa",
"accessibility.bestPractice": true,
"accessibility.excludeRules": ["color-contrast", "image-alt"],
"accessibility.excludeRuleCategories": "aria",
};
capabilities['accessibility'] = true;
capabilities['accessibility.wcagVersion'] = 'wcag21aa';
capabilities['accessibility.bestPractice'] = true;
capabilities['accessibility.excludeRules'] = ['color-contrast', 'image-alt'];
capabilities['accessibility.excludeRuleCategories'] = 'aria';
A comma-separated string is accepted wherever an array is, which is convenient in configuration files and CI variables:
"accessibility.excludeRules": "color-contrast,image-alt",
"accessibility.excludeRuleCategories": "aria,tables"
HyperExecute. Pass the same capabilities from your test code. They are read and validated by the same logic as on the cloud grid, so nothing in hyperexecute.yaml needs to change. See HyperExecute: Selenium accessibility automation.
How the effective rule set is resolved
Exclusion is applied on top of the existing scan configuration. Every step only removes rules, so an exclusion can never add a rule back, and the first step that removes a rule is the reason recorded for it:
- WCAG version and level. Cumulative, as before:
wcag21aaincludes every WCAG 2.0 and 2.1 rule at level A or AA. - Best Practices toggle. Best Practice rules are removed while
accessibility.bestPracticeisfalse. This is the only rule-level group toggle on web. - Excluded categories. Every rule in a category named in
accessibility.excludeRuleCategoriesis removed. - Excluded rules. Every rule named in
accessibility.excludeRulesis removed.
Consequences of this order:
- A rule named in
excludeRulesthat also belongs to an excluded category is attributed to the category, and the duplicate entry is ignored without error. - A rule that is already outside the WCAG range and is also named in
excludeRulesis a silent no-op. - A Best Practice rule named in
excludeRuleswhileaccessibility.bestPracticeisfalseis attributed to the toggle, not to the exclusion.
accessibility.needsReview is not part of exclusion. It filters uncertain results after a rule has run, and a single rule can produce both a violation and a needs-review item in the same scan, so there is nothing rule-level to exclude. It never appears as a row in Applied Settings.
What happens at session creation
Exclusions are validated when the session is created, before a browser is allocated. This applies on the cloud grid and on HyperExecute.
| Input | Outcome |
|---|---|
| Valid rule ID or category slug | Applied |
| Unknown rule ID | Logged and dropped; the session proceeds |
| Unknown category slug | Logged and dropped; the session proceeds |
| AI rule ID passed on an automation session | Dropped; AI rules do not run on automation |
| Wrong type (a number, for example) | The capability is ignored with a warning; the session proceeds |
| Every entry invalid | The scan runs with the full configured rule set |
| Exclusions remove every in-scope rule | Session creation is rejected. No test is created and no browser is allocated |
| Rule catalog temporarily unreachable | The lists are applied as written without validation; the scan still refuses to run against an empty rule set |
| Session is a real-device mobile browser | Rejected. The capabilities support desktop web and native Android and iOS apps only |
A misspelled rule ID or category never fails your functional test. The scan runs with whatever exclusions were valid, and the session log records which entries were dropped and why.
Excluding every rule rejects the session
If the exclusions leave nothing to evaluate, whether by naming every rule, excluding every category, or a mix of both, the session is refused at creation with an HTTP 400 error. The error surfaces at driver initialisation in your test, no test record is created, and no browser time is used. The message states how many rules were in scope and how many each list removed, in this form:
All <N> rules in scope for WCAG 2.1 AA were excluded by this configuration (<n> by category, <n> by rule).
Include at least one rule to run an accessibility scan. Remove a value from accessibility.excludeRuleCategories
or accessibility.excludeRules, or set accessibility=false to disable accessibility scanning for this session.
Remove at least one entry, or set accessibility to false if that session should not run an accessibility scan at all.
What to expect in results
- Filtered before execution. An excluded rule is switched off in axe before the scan runs. It is absent from the findings and from the score by construction, not filtered out of the results afterwards.
- Score reflects the evaluated set. The accessibility score is computed only over the rules that ran.
- Applied Settings on every web report. The Applied Settings popover, previously available only on mobile app reports, now appears on every web report. It groups the rules by category. An excluded category is greyed out, and an individually excluded rule is shown as Off.
- Reproducible. Both lists are stored with the test and returned by the test-detail API, so any historical result can be reproduced. Merged reports fold in the lists of their source reports.
FAQ
Can I exclude a rule for one page only?
No. Exclusions apply to every scan in the session, including scans triggered by accessibility.autoscan. To suppress a single finding after the fact, use Hide and Restore Issues.
Is there an include list? No. Exclusion only removes rules. To run a narrower set, lower the WCAG target or switch off Best Practices, then exclude what remains.
Can I exclude a single element or selector rather than a rule? No. Exclusion works at rule and category level. Use Hide and Restore Issues for a specific element in a report.
Why does my exclusion not appear in the report? Check the session log for a dropped entry (a misspelled ID or slug), and check whether the rule was already removed by the WCAG range or the Best Practices toggle. A rule removed earlier in the resolution order is attributed to that step, not to the exclusion.
Do the capabilities work on Cypress or on real-device mobile browsers? This release supports Selenium and Playwright sessions on desktop browsers, on the cloud grid and on HyperExecute. Cypress is not part of this release. A session on a real-device mobile browser is rejected.
Do I need to change anything if I do not use exclusions? No. The capabilities are opt-in. A session that sets neither produces the same rule set as before.
Related docs
- Configure Accessibility Automation
- Accessibility Automation (Overview)
- Selenium: Accessibility Automation setup
- Playwright
- HyperExecute: Selenium accessibility automation
- Rule and Category Exclusion in DevTools and Scheduled Scans
- Rule and Category Exclusion for Mobile App Accessibility
- Hide and Restore Issues
- Web Rule Repository
