feat(web): read range widgets in toHaveValue
Closed
AS
19h ago+298+298+012345678901234567890123456789-11-11-01234567890123456789
What and why
toHaveValuereads a node'svalue, but the web reader set one only on native form controls, so an ARIAslider,spinbutton,progressbar,meter, orscrollbar, and a native<progress>or<meter>, could not be asserted on.- A locator read now gives those roles their
aria-valuetext, elsearia-valuenow, skipping a blank one. A native<progress>or<meter>with avalueattribute then reads the value its range clamps it to, as Chrome does. Asliderorspinbuttonwith none reads'', as before, any other widget with none has no value, and a strayvalueattribute on it is not read. A native value is computed from thevalue,min, andmaxattributes as HTML clamps them, never through.value, so a page's own getter (a customized built-in<progress is>) never runs; it equals Chrome's.valueon 6,510 attribute combinations. Native form controls and editors read as before, a control adopted from another frame included. locator.inputValue()reads the same field, so it returns these values too. Playwright's throws on an ARIA widget. I kept the two paired because the docs describe them together and mobile already works this way. If you'd rather keepinputValue()to form controls, that's a small follow-up here.- The agent's tree does not get this value, so what the model reads, the replay cache's evidence, and committed recordings do not change.
- The MCP
locatetool now prints a range widget's value too (value "50"), through the same redaction as any other value. - On iOS, nodes already carry an accessibility value outside the form roles (the captured trees show
status "In progress" value="1"), so the matcher reads them today. Android drops the value of a non-editable node when it repeats the node's label, so that case usestoHaveText, and the Detox guide says so. - Docs:
reference/expect.mdx,reference/screen.mdx, the Detox guide (a "Not yet" row now covers only that Android case), and thewriting-testsskill line.
Issue
Part of #1855: expect(locator).toHaveValue('On'). @okwasniewski, this is ready for review.
Verified
Ran it locally: yes
to-have-value-widgets.test.tsruns the public locator and matcher on a real page: ARIA slider,aria-valuetext, spinbutton, progressbar,<progress>,<meter>, over-max and invalid native values, a blank ARIA value, an editable spinbutton, a native range input that keeps its own value, and widgets with no value that are still refused. It fails on main's web source and passes here.- A new case in
read-node-checked.test.tspins that the agent's tree still has no value for a range widget, and one in the mobilelocate.test.tspins the device projection, including the Android label echo. pnpm check, the fullpnpm test(8,082 passed), the testbed (598 passed, 3 skipped), and the web suite pass. A hostile-page audit (70 pages, 13 locator reads each) finds no read that works on main and fails here. Each clamp, the attribute parser, and the adopted-control guard fail a test when broken.- Not run on a device: no mobile code changed.
Checklist
- Changeset added (
pnpm changeset) for any change to a published package, or the change is testbed, docs, or CI only. - Breaking change: title carries
!, the changeset body names what breaks and what replaces it, and the deprecation warning landed a window earlier (stability policy in CONTRIBUTING.md). - Docs updated in the same PR: the
docs/**/*.mdxpage for the behavior, andskills/e2e/if the skill describes it. - Contract change: emitted
.d.tsreviewed,tests/types/sdk-types.tsupdated; wire change edits the schema and both fixtures. - Engine contract change (
e2e/engine): changesets fore2e,@e2e-dev/web, and@e2e-dev/mobile.