Skip to main content

Accessibility

DrevOps\BehatSteps\Steps\Web\AccessibilityTrait - Source, Example, Helpers

Assess accessibility of rendered pages.

Supported tags:

  • @accessibility Auto-mode, default threshold.
  • @accessibility:critical Auto-mode, fail only on critical impact.
  • @accessibility:serious Auto-mode, fail on critical or serious.
  • @accessibility:moderate Auto-mode, fail on critical / serious / moderate.
  • @accessibility:minor Auto-mode, fail on any impact.
  • @accessibility:any Auto-mode, fail on any impact (alias).
  • @accessibility:warning Auto-mode, never fail (advisory).
  • @accessibility:strict Also fail on "incomplete" findings.
  • @behat-steps-skip:AccessibilityTrait Opt the scenario or feature out entirely.

Tool-agnostic. Any engine that runs inside the existing Mink session can be plugged in by overriding accessibilityRunEngine() and accessibilityNormalizeResults(). 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-page accessibility_report_<timestamp>.html (timestamp YYYYMMDD_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 the BEHAT_ACCESSIBILITY_PRINT environment variable to a non-empty value other than 0, or override accessibilityGetPrintCli(), to enable it.

Options​

OptionTypeDefaultTagDescription
accessibility.enabledbooleanTRUE@behat-steps-skip:AccessibilityTraitAssess every page an @accessibility scenario visits.
accessibility.auto_tagstring'accessibility'-Base tag name, without its @, that puts a scenario into automatic mode.
accessibility.default_rulesstring'wcag2a,wcag2aa'-Rule identifier passed to the engine when a scenario names none.
accessibility.failure_thresholdstring'any'-Impact level at which a violation fails the scenario: any, never, or one impact identifier.
accessibility.fail_on_incompletebooleanFALSE-Fail the scenario on a finding the engine could not decide.
accessibility.cdn_urlstring'https://cdn.jsdelivr.net/npm/axe-core@4.11.4/axe.min.js'-Location the engine source is read from.
accessibility.fetch_timeoutinteger10-Per-attempt timeout, in seconds, for the engine fetch.
accessibility.fetch_attemptsinteger3-How many times the engine fetch is attempted before failing.
accessibility.report_dirstring'.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"