Appendix C. Examples
Permalink to Appendix C. ExamplesThis appendix is informative.
C.1 A positive case
Permalink to C.1 A positive caseid: login-success
title: 'Log In To The System'
type: positive
description: 'Verify that a user with valid credentials can log in.'
preconditions:
- 'User has a valid username and password'
- 'User is not already logged in'
start_location: 'https://www.example.com'
expected_result: 'The user is logged in and redirected to the dashboard'
data:
username: '[email protected]'
password: 'xyzpdq123!)'
dashboard_url: 'https://www.example.com/dashboard'
steps:
- locate: link "Client Sign In"
- focus: link "Client Sign In"
- activate: link "Client Sign In"
- verify: url "https://www.example.com/login.php"
- locate: field "username"
- focus: field "username"
- enter: field "username" value "{{ username }}"
- locate: field "password"
- focus: field "password"
- enter: field "password" value "{{ password }}"
- locate: button "Login"
- focus: button "Login"
- activate: button "Login"
- verify: url "{{ dashboard_url }}"
C.2 A negative case extending C.1
Permalink to C.2 A negative case extending C.1id: login-error-short-password
title: 'Log In — Alt 1 (Error State)'
type: negative
extends: login-success
description: 'Trigger error handling by providing a too-short password'
data:
password: 'abc'
steps_override:
from_step: 11
steps:
- 'activate: button "Login"'
- 'verify: alert "Errors are preventing successful submission of this form."'
- 'verify: field_error "password"'
After resolution, this case re-uses the parent's first 10 steps with
password: 'abc' re-interpolated, then runs the three override steps.
C.3 An audit step inside a workflow
Permalink to C.3 An audit step inside a workflow- audit: page level "AA"
- activate: button "Search"
- audit: region "Search Results"
The first audit checks the whole page; the third checks only the search results region after the search completes.
C.4 The minimum viable case
Permalink to C.4 The minimum viable caseid: smoke
title: 'Site renders'
type: positive
start_location: 'https://www.example.com'
expected_result: 'A landing page is shown'
steps:
- locate: heading "Welcome"
C.5 An iterated audit-shaped case
Permalink to C.5 An iterated audit-shaped caseid: every-image-has-alt
title: 'Every image on the page exposes an accessible name'
type: positive
start_location: 'https://www.example.com'
expected_result: 'Every img has alt text other than the empty string'
scope:
for_each: 'role "img"'
steps:
- locate: self
- verify: self attribute "alt" present
This produces an iterations array in the report — one entry per img on the
page — plus an iteration_summary with total, passed, failed, and
inapplicable counts. If the page has zero images the case is reported as
inapplicable, not as a failure.
C.6 An iterated case using a consumer-supplied criteria
Permalink to C.6 An iterated case using a consumer-supplied criteriaid: headings-are-not-skipped
title: 'No heading skips levels relative to its predecessor'
type: positive
start_location: 'https://www.example.com'
expected_result: 'Each heading is at most one level deeper than its predecessor'
scope:
for_each: 'criteria sequential_headings'
steps:
- locate: self
- verify: self attribute "data-level-jump" is "ok"
The host process supplies a resolver for the sequential_headings criteria via
RunOptions.criteriaResolver; the resolver returns either a CSS selector string
or an array of locators. When no resolver is configured the runner fails the
case with a clear error.