Accessibility
DrevOps\BehatSteps\Steps\Web\AccessibilityTrait - Source, Example, Helpers
Assess accessibility of rendered pages.
Supported tags:
@accessibilityAuto-mode, default threshold.@accessibility:criticalAuto-mode, fail only on critical impact.@accessibility:seriousAuto-mode, fail on critical or serious.@accessibility:moderateAuto-mode, fail on critical / serious / moderate.@accessibility:minorAuto-mode, fail on any impact.@accessibility:anyAuto-mode, fail on any impact (alias).@accessibility:warningAuto-mode, never fail (advisory).@accessibility:strictAlso fail on "incomplete" findings.@behat-steps-skip:AccessibilityTraitOpt the scenario or feature out entirely.Tool-agnostic. Any engine that runs inside the existing Mink session can be plugged in by overriding
accessibilityRunEngine()andaccessibilityNormalizeResults(). The first performs the assessment and returns raw results; the second remaps raw output into the canonical shape the rest of the trait reads.
Reporting. Each scenario writes its own HTML and JUnit report. After the whole suite, a single cross-pageaccessibility_report_<timestamp>.html(timestampYYYYMMDD_HHMMSS) is written to the same directory, de-duplicating every assessed page and rolling violations up by rule.
1 file is written per run, so a run never overwrites a previous one. The aggregate accumulates in process-global state, so under parallel Behat each process writes its own report.
Console output. A 1-line per-page summary can be printed to the console as pages are assessed. Printing is off by default; set theBEHAT_ACCESSIBILITY_PRINTenvironment variable to a non-empty value other than0, or overrideaccessibilityGetPrintCli(), to enable it.
Options
| Option | Type | Default | Tag | Description |
|---|---|---|---|---|
accessibility.enabled | boolean | TRUE | @behat-steps-skip:AccessibilityTrait | Assess every page an @accessibility scenario visits. |
accessibility.auto_tag | string | 'accessibility' | - | Base tag name, without its @, that puts a scenario into automatic mode. |
accessibility.default_rules | string | 'wcag2a,wcag2aa' | - | Rule identifier passed to the engine when a scenario names none. |
accessibility.failure_threshold | string | 'any' | - | Impact level at which a violation fails the scenario: any, never, or one impact identifier. |
accessibility.fail_on_incomplete | boolean | FALSE | - | Fail the scenario on a finding the engine could not decide. |
accessibility.cdn_url | string | 'https://cdn.jsdelivr.net/npm/axe-core@4.11.4/axe.min.js' | - | Location the engine source is read from. |
accessibility.fetch_timeout | integer | 10 | - | Per-attempt timeout, in seconds, for the engine fetch. |
accessibility.fetch_attempts | integer | 3 | - | How many times the engine fetch is attempted before failing. |
accessibility.report_dir | string | '.logs/test_results/accessibility' | - | Directory the per-scenario reports are written to. A relative path resolves against the directory the run was launched from. |
Steps
@Then the page should pass accessibility checks
Assert that the current page passes accessibility checks
Then the page should pass accessibility checks
@Then the page should pass accessibility checks for the tags :tags
Assert that the current page passes accessibility checks for given tags
Then the page should pass accessibility checks for the tags "wcag2a"