What Your End-to-End Suite Isn't Telling You
A companion essay to "Testing the Way Users Actually Experience the Web" — a
tutorial series on @afixt/usecase-runner. Each point below is covered in
depth, with a runnable example, elsewhere in the series.
Here is an end-to-end test of the kind most teams have hundreds of:
test('newsletter rejects an empty email', async ({ page }) => {
await page.goto('https://app.example.com/newsletter');
await page.locator('.subscribe-btn').click();
await expect(page.locator('.error-text')).toBeVisible();
});
It is green. It will stay green if the button is a <div> nobody can tab to, if
the error text is announced to no one, and if a screen-reader user submits the
form and hears nothing at all. The test isn't wrong about what it checks. It is
silent about everything that decides whether a person can actually use the
page.
That silence isn't one bug. It is a set of habits built into how end-to-end tests are usually written. Here are thirteen of them, and what the Accessibility Use Case Definition Language (UCDL) does about each.
How elements are found
Permalink to How elements are found1. Selectors describe how the page is built, not how it is used. #name,
.btn-primary and an XPath expression all reach around the interface and grab
the DOM directly. A <div class="btn"> with no role, no name and no place in
the tab order is found just as easily as a real button.
UCDL targets elements by role and accessible name. CSS selectors and XPath
are not part of the surface language, and a role target resolves through the
accessibility tree: an element that is visually present but hidden from
assistive technology makes the step fail, and the failure is the finding. Two
narrow escape hatches, id and data-*, do resolve through CSS, and the
specification discourages them for precisely that reason; the field and text
tokens read the DOM rather than the tree. Where exposure is the point of a step,
target it by role — see
Why Your Test Selectors Are Lying to You.
2. A green suite says nothing about who can use the product. Functional tests and accessibility tests usually live in separate suites, run by separate people, on separate schedules. A passing functional run is no evidence either way about a keyboard or screen-reader user.
In UCDL they are one artifact. A flow whose targets are roles and accessible
names is a functional test and an accessibility test in the same steps: it
cannot complete unless the controls it names are exposed to assistive
technology. That holds for the role targets. A step written against the field,
text, id or data-* tokens reaches the DOM directly and asserts nothing
about exposure — which is why the specification says to target by role wherever
exposure is the point.
What actions mean
Permalink to What actions mean3. Actions describe gestures, not outcomes. click() dispatches a pointer
event at some coordinates. focus() is called, and nothing checks that focus
arrived.
UCDL verbs are contracts about what the user experienced. focus asserts that
the element actually received focus; the specification calls an unverified
focus() non-conforming. activate ... via keyboard presses a key rather than
clicking. See
locate, focus, activate.
4. The test runner always has a mouse. A test runner can hover over anything at any time, so a mega-menu that opens only on pointer-over passes — for the runner, and not for anyone navigating by keyboard, switch or voice. That is not a defect in Playwright, which the runner is built on. It is that nothing in a conventional suite ever asks whether the pointer was necessary.
UCDL makes the pointer an explicit choice. Run with --profile no-pointer and
every step form that dispatches a pointer event is refused: hover,
hover_out, toggle, an activate that isn't via keyboard, and select on
an option target. A forbidden step fails without executing, because the
assertion is that the flow needs the affordance at all. The specification is
careful about the other direction: a clean run establishes that the script as
written requires no pointer, which is the author's claim about the flow — not
proof that the application offers no mouse-only path. See
Testing Without a Mouse.
5. Setting a state looks the same as toggling it. Most tests click a disclosure once and check that it opened. A component that opens and never closes passes.
UCDL keeps the two apart. select is idempotent on a checkbox or radio — it
means set to on — and toggle fails unless the control's state actually
changed. See
select Is Not toggle.
What assertions check
Permalink to What assertions check6. Verification checks what's painted, not what's announced.
toBeVisible('.error-text') passes whether or not any assistive technology ever
learns the error exists.
UCDL asserts the semantics. verify: alert requires role="alert".
verify: field_error requires both aria-invalid="true" and an
aria-describedby or aria-errormessage reference to a visible message —
either alone is insufficient. verify: live_region searches every real live
region on the page, not one picked by role priority. See
Verify Like a Screen Reader, Not Like a Screenshot.
7. Some assertions quietly check nothing. A lenient parser can drop a clause it doesn't understand and run what is left. The step still reads as an assertion and still goes green. The failure mode is specific, and worse than a missing test: the dropped clause can be the only accessibility assertion in the step, so the step's pass gets read as a fix for the very thing it stopped checking.
UCDL treats unconsumed input as a parse error, and every action verb rejects a modifier it doesn't know. The error names the offending token, so a typo is caught at validation rather than discovered never. See Strictness Is a Feature.
Who can read the test
Permalink to Who can read the test8. Only developers can read the tests, and the test plan drifts. The manual test plan lives in one place and the automation in another, and nothing keeps them in step.
A use case document is YAML that a QA tester can write and a product owner can read. It carries its preconditions, its expected result and its intent, so the test plan and the test are the same artifact. See A Test Your QA Team Can Actually Read.
9. Error paths are tested ad hoc, if at all. The happy path gets a test; the error states, where accessibility most often breaks, get whatever time is left.
UCDL types every case as positive or negative, recording whether it
exercises a happy path or an error path. Branching is a separate mechanism: an
extension case declares extends and a steps_override, splicing new steps
into its parent at a named anchor and inheriting everything before it — so an
error path costs the steps that differ rather than a second copy of the flow.
See
One Flow, Many Outcomes.
What the results say
Permalink to What the results say10. Pass and fail are too coarse. A manual tester's report is full of "passed, but note that…" — and a broken log-in looks exactly like a defect in the page under test.
UCDL scores five outcomes. Pass. Pass w/ Conditions, for a run in which
everything that ran passed but a step was skipped or carried a note from one of
three enumerated sources — a low-priority audit issue, a skipped contrast
measurement, or an escape-hatch target. Fail. Inapplicable, for a run in
which no assertion was evaluated at all. And Error, for a run whose before
block failed, so the steps under test never ran.
Error says nothing about the page: the case never reached the behaviour it
exists to judge. Neither does Inapplicable, for the opposite reason — the run
completed and evaluated nothing. Individual failures can be uninformative too,
and the report says which: a step that fails because its audit engine or
screen-reader driver would not start carries
failure_reason: dependency_unavailable, which the specification calls an
environment failure rather than evidence about the page.
11. The first failure ends the run. One failure per run means one finding per run, and a long fix-and-rerun loop.
UCDL keeps going by default — continue_on_failure is true — the way a manual
tester doesn't close the laptop at the first defect. Two deliberate bounds on
that. A failure in the before block halts unconditionally, whatever the
setting, because nothing after a broken setup can be trusted. And inside a
scope.for_each sweep the setting governs a single iteration, so the next
element is swept either way. When a run does report several failures, step order
is what lets you see which one came first. See
Generate for CI, Run for Right Now.
12. Scanners and flow tests never meet. A scanner is usually pointed at a URL and sees the page as it loads — not after log-in, with the dialog open, or with the form in its error state, which are the moments that matter.
UCDL puts the scanner inside the flow. audit, contrast and lang_check run
at any step, against the page exactly as the flow left it, and scope.for_each
turns a case into a sweep over every matching element. See
Beyond the Step.
13. Results don't say how they were produced. A green tick rarely records which browser, which runner, or which shortcuts the test took.
A UCDL report carries a tester string, and the specification recommends — and
a later major version will require — an environment record that includes the
processor and its version, the automation engine, the browser build, the
operating system, the viewport the run started at, and the screen-reader driver
the session was actually started with rather than the one requested. A step that
uses one of the id or data-* escape hatches — which prove nothing about
exposure to assistive technology — should be flagged in the report.
The same test, rewritten
Permalink to The same test, rewrittenHere is the newsletter test again, written as a use case:
# newsletter-empty-email.uc.yaml
id: newsletter-empty-email
title: 'Newsletter sign-up rejects an empty email accessibly'
type: negative
start_location: 'https://app.example.com/newsletter'
expected_result:
'The error is announced, the field is marked invalid, focus moves to it, and
the page in its error state passes an audit'
preconditions: []
steps:
- locate: field "Email"
- locate: button "Subscribe"
- focus: button "Subscribe"
- activate: button "Subscribe" via keyboard
- verify: alert "Enter your email address"
- verify: field_error "Email"
- verify: focus field "Email"
- verify: url "/newsletter"
- audit: page
npx usecase-runner run newsletter-empty-email.uc.yaml --profile no-pointer
Against a page where the button is a <div> and the error is a styled
paragraph, the original test passes and this one fails — at the button, at the
announcement, at the field, at the focus move. It runs under no-pointer
without changes, because nothing in it needs a mouse. Each of those failures
names something the page does not expose to assistive technology, and each is
answered in the page rather than in the test. Read the report rather than the
count: the specification marks some failures as environment problems rather than
findings, and a focus step that passes establishes programmatic focus, not
that a keyboard user can tab to the control.
What it doesn't fix
Permalink to What it doesn't fixUCDL is not a replacement for everything else, and it's worth being plain about where it stops.
- It is slower per issue than a rule-based scanner, and it doesn't point to code. The methodology says so directly: use case testing tells you whether a task can be completed, not which line of code is responsible.
- It doesn't replace automated scanners. A scanner is broad and shallow; a use case is narrow and deep. You want both.
- The escape hatches prove nothing about exposure. A step targeted by
idordata-*reaches the element through CSS, and establishes nothing about whether assistive technology can perceive it. - A
focusstep that passes is not a reachable control. It establishes that the element accepts programmatic focus. An element withtabindex="-1"acceptsfocus()and passes while sitting outside the tab order, so a flow written as a sequence offocussteps can go green against a page whose tab order is broken. Reachability is a separate assertion: drive the keyboard and check where focus landed. - An empty sweep is not a pass — but it is not a finding either. If a
scope.for_eachcollection matches nothing, the case scoresinapplicablerather thanpass, deliberately: deleting every matching element must not make a sweep go green. It still isn't a defect report, so when the collection's existence is itself what you care about, assert it with a terminalverify: iteration_summary.total is Nwhere the count is known. - Checking ARIA semantics is not hearing a screen reader. That is why a report states whether a virtual or a real screen reader produced what was announced.
Start here
Permalink to Start herenpm install @afixt/usecase-runner @playwright/test @afixt/afixt-engine
npx playwright install
npx usecase-runner init
@afixt/afixt-engine is an optional peer dependency, and audit delegates to
it — including the audit: page step above. Without it that step fails with
failure_reason: dependency_unavailable, which the specification calls an
environment failure rather than a finding about the page. Install it alongside
the runner if your cases audit.
Pick the flow your suite is proudest of and rewrite it as a use case. Read the failures as a list of things the page does not expose or does not do — from the report rather than the count, because some failures are environment problems rather than findings. Then start with the introduction to the series, which takes each of the points above one at a time.