Repository navigation
feat(web): read range widgets in toHaveValue (ENG-1259) - #2242
Conversation
The web reader set a value only on native form controls, so toHaveValue could not read an ARIA slider, spinbutton, progressbar, meter, or scrollbar, or a native progress or meter. A locator read now gives them aria-valuetext, else aria-valuenow, else the value attribute. The agent tree is unchanged. Part of #1855.
… the docs A generic element with a range role but no aria-valuenow/aria-valuetext no longer reads a stray value attribute; only a native progress or meter reads a non-aria value, as Chrome reports. The docs qualify the clamp to valued progress/meter, note an indeterminate progress is refused, name the Playwright inputValue throw, and drop a verb-less fragment. Adds scrollbar and indeterminate-progress tests.
…e case A progress or meter adopted from another frame keeps that frame's prototype, so instanceof missed it. The read now goes by tag. The indeterminate progress gets its own expected-failure test, since the assertion after a failing one never ran, and the comment says only the native clamp follows Chrome.
Replaces the hand-written float parser and clamps with the prototype's own value getter, so a <progress> or <meter> reads what the browser parses (Firefox and WebKit differ from Chromium on trailing text and overflow) while a customized built-in's override still never runs. An element outside the HTML namespace is refused, since the HTML getter throws on it.
🟢 e2e web: 95 passedAll 95 tests in 43 files
Tested by e2e 0.24.0 · 1m 4s · web · run artifacts |
🟢 e2e web agent: 34 passed36 agent steps · 26 replayed from cache · 26 model calls · 135.0k tokens (93% cached) · $0.0060 All 34 tests in 5 files
Tested by e2e 0.24.0 · 1m 36s · web · run artifacts |
🟢 e2e android agent: 20 passed24 agent steps · 15 replayed from cache · 36 model calls · 218.1k tokens (79% cached) · $0.0165 All 20 tests in 1 file
Tested by e2e 0.24.0 · 5m 14s · android-emulator · run artifacts |
🟢 e2e ios: 1 flaky, 61 passed, 1 skipped
|
| Test | Time | |
|---|---|---|
| tests/device-fixture.e2e.ts · 1 flaky, 13 passed | 2m 0s | |
| 🟢 | device fixture › setAppearance flips the color scheme the app reads | 14.3s |
| 🟢 | device fixture › setOrientation rotates the window and viewport dimensions | 7.4s |
| device fixture › the clipboard reads back what was written (1 failed attempt first) | 5.4s | |
| 🟢 | device fixture › home leaves the app, openApp brings it back where it was | 6.8s |
| 🟢 | device fixture › closeApp then openApp relaunches on the home list | 8.1s |
| 🟢 | device fixture › closeApp leaves the next commands on the same device | 12.1s |
| 🟢 | device fixture › foregroundApp after closeApp reports the closed session as APP_NOT_OPEN | 5.8s |
| 🟢 | device fixture › openLink opens the scenario a deep link names | 13.2s |
| 🟢 | device fixture › isAppInstalled finds the app under test and no app that is absent | 6.8s |
| 🟢 | device fixture › uninstallApp removes the app until installApp puts it back | 10.0s |
| 🟢 | device fixture › device.back pops the scenario | 5.8s |
| 🟢 | device fixture › unstable_raw reaches the test session through the raw driver | 4.3s |
| 🟢 | device fixture › setLocation and clearLocation change what the app reads | 9.9s |
| 🟢 | device fixture › enrollBiometrics and setBiometrics answer a biometric prompt | 10.1s |
| ⏭️ | tests/controls.e2e.ts · 24 passed, 1 skipped | 3m 0s |
| 🟢 | control inventory › a label query resolves a labeled text field | 12.1s |
| 🟢 | control inventory › a labeled field answers name, display value, value reads, fill, and clear | 13.5s |
| 🟢 | control inventory › a placeholder query and attribute reads find the field | 4.9s |
| 🟢 | control inventory › a secure field takes a fill and denies value reads | 7.5s |
| 🟢 | control inventory › press sends a character and Enter through the soft keyboard | 9.2s |
| 🟢 | control inventory › a field autofocuses on mount and focus() moves the focus | 9.5s |
| 🟢 | control inventory › toBeFocused follows the focus | 8.5s |
| 🟢 | control inventory › a switch checks, unchecks, and reports its state | 9.6s |
| 🟢 | control inventory › checkbox and radio roles answer getByRole, and a checkbox toggles by tap | 8.4s |
| 🟢 | control inventory › checkbox and radio roles check, uncheck, and report their state | 12.9s |
| 🟢 | control inventory › a radio group reports the checked option | 8.6s |
| 🟢 | control inventory › buttons report disabled, enabled, and a state that arrives later | 7.4s |
| 🟢 | control inventory › a display: none element is absent rather than hidden, its visible twin attached | 7.0s |
| 🟢 | control inventory › a header answers its accessible name | 4.3s |
| 🟢 | control inventory › a tab row answers count, all, texts, filters, positions, and switching | 6.2s |
| 🟢 | control inventory › a list answers counts, list-form text, reads, and boxes in order | 6.5s |
| ⏭️ | control inventory › a row contains its texts (skipped: React Native flattens a plain View out of the accessibility tree on both platforms: XCTest and the Android helper report a View with a testID as a leaf beside its children, so filter({ has }) and a query scoped to it match nothing; only Sc…) | |
| 🟢 | control inventory › a long press lands as one | 8.2s |
| 🟢 | control inventory › tap({ count: 3 }) lands three presses | 8.1s |
| 🟢 | control inventory › pointer verbs land at the point asked for | 8.9s |
| 🟢 | control inventory › an ambiguous locator fails at once | 5.5s |
| 🟢 | control inventory › screenshot, restart, and clearState reopen the app on its home list | 12.2s |
| 🟢 | refusals › verbs a device never declares are refused before the engine | 2ms |
| 🟢 | refusals › keys the soft keyboard cannot send are refused by the engine | 185ms |
| 🟢 | refusals › a missing locator fails as not found once its timeout passes | 1.1s |
| 🟢 | tests/device.e2e.ts · 6 passed | 1m 9s |
| 🟢 | permissions all grants the microphone without a system dialog | 11.4s |
| 🟢 | sequential onboarding echoes the exact values | 24.6s |
| 🟢 | isKeyboardShown follows the keyboard up and through a dismissal | 7.6s |
| 🟢 | a shake is sent without an error and leaves the screen readable | 4.8s |
| 🟢 | onboarding rejects a malformed email before advancing | 9.8s |
| 🟢 | dismissing the keyboard over choice controls leaves them as they were | 10.7s |
| 🟢 | tests/flows-lists.e2e.ts · 7 passed | 3m 57s |
| 🟢 | infinite scroll reaches the target item | 34.5s |
| 🟢 | product catalog adds exactly two of the right variant | 10.0s |
| 🟢 | gestures: long-press, then swipe left | 8.5s |
| 🟢 | sticky chrome: accept below the fold, then continue | 12.4s |
| 🟢 | async states: load, pull to refresh, claim through the toast | 12.6s |
| 🟢 | huge virtualized list reaches row 512 | 2m 26s |
| 🟢 | web view coupon form applies the code shown on the page | 12.5s |
| 🟢 | tests/flows.e2e.ts · 7 passed | 1m 8s |
| 🟢 | text inputs unlock the submit button | 12.3s |
| 🟢 | filled text inputs report their values | 10.6s |
| 🟢 | modal flow confirms through the native alert | 9.6s |
| 🟢 | bottom tabs act inside the last tab | 7.3s |
| 🟢 | error recovery retries, then confirms the delete | 9.3s |
| 🟢 | choice controls place the exact order | 7.4s |
| 🟢 | debounced search selects the target once results arrive | 11.1s |
| 🟢 | tests/login-form.e2e.ts · 3 passed | 46.1s |
| 🟢 | login form › rejects a malformed email | 13.1s |
| 🟢 | login form › rejects an unknown account | 13.1s |
| 🟢 | login form › signs in and logs out | 19.8s |
| 🟢 | tests/smoke.e2e.ts · 1 passed | 8.9s |
| 🟢 | home lists the scenarios and opens one | 8.9s |
Tested by e2e 0.24.0 · 6m 59s · ios-simulator · run artifacts
🟢 e2e android: 63 passed, 1 skippedAll 64 tests in 7 files
Tested by e2e 0.24.0 · 9m 29s · android-emulator · run artifacts |
🟢 e2e ios agent: 1 flaky, 20 passed, 1 skipped25 agent steps · 11 replayed from cache · 66 model calls · 650.1k tokens (84% cached) · $0.0428
|
| Test | Agent | Time | |
|---|---|---|---|
| tests-agent/scenarios.e2e.ts · 1 flaky, 20 passed, 1 skipped | 25 steps · 66 calls | 8m 41s | |
| 🟢 | act completes Login Form | 1 step · 6 calls | 1m 10s |
| 🟢 | act completes Infinite Scroll List | 1 step | 37.5s |
| 🟢 | act completes Modal Flow | 1 step | 9.9s |
| 🟢 | act completes Bottom Tabs | 1 step | 7.3s |
| 🟢 | act completes Text Input Variations | 1 step | 12.6s |
| 🟢 | act completes Broken Accessibility | 2 steps · 6 calls | 22.1s |
| 🟢 | act completes Vision Only | 2 steps · 6 calls | 24.4s |
| act completes Gestures (2 failed attempts first) | 1 step · 12 calls | 54.3s | |
| 🟢 | act completes Async States | 1 step · 7 calls | 21.0s |
| 🟢 | act completes Debounced Search | 1 step · 1 call | 28.2s |
| 🟢 | act completes Flattened Registration Form | 2 steps · 1 call | 25.4s |
| 🟢 | act completes Flattened Login | 2 steps · 10 calls | 48.6s |
| 🟢 | act completes Sticky Chrome Target | 1 step | 13.0s |
| 🟢 | act completes WebView Accessibility | 1 step | 11.5s |
| 🟢 | act completes Permission Prompt | 1 step | 11.9s |
| 🟢 | act completes Photo Picker | 1 step · 2 calls | 29.1s |
| 🟢 | act completes Product Catalog | 1 step | 10.4s |
| 🟢 | act completes Error Recovery | 1 step | 10.5s |
| 🟢 | act completes Choice Controls | 1 step · 6 calls | 33.1s |
| 🟢 | act completes Stripe PaymentSheet | 1 step · 9 calls | 29.1s |
| 🟢 | act completes Apple Pay | 1 step | 10.7s |
| ⏭️ | act completes Apple Pay Billing Address (skipped: the CI simulator's Apple Pay sheet skips the billing-address step, so the scenario cannot be completed there) |
Tested by e2e 0.24.0 · 10m 50s · ios-simulator · run artifacts
|
[claude-opus-5-5] responding on behalf of @KrzysztofMoch Green and labeled. Four things need a human:
|
What
expect(locator).toHaveValueandlocator.inputValue()read ARIA range widgets on the web: aslider,spinbutton,progressbar,meter, orscrollbarthat is not a native form control reads itsaria-valuetext, else itsaria-valuenow. A native<progress>or<meter>with avalueattribute reads the browser's own clamped.value.Why
The web reader set a node's
valueonly on native form controls, sotoHaveValue('50')on<div role="slider" aria-valuenow="50">failed withobserved: value "". Mobile already reports these values. Playwright'stoHaveValueandinputValue()throwNot an input elementon these nodes, so reading a value turns a throw into a passing assertion and changes no migrated test.inputValue()diverging from Playwright here is deliberate (maintainer decision): it reads whattoHaveValuecompares, as it already does on mobile.This takes over #2061 by @Asheesh7298, rebased onto main, with the last review round addressed. Their commits are kept as they wrote them.
How it works
rangeValueOf(packages/web/src/in-page/read-semantics.ts:664). A blank ARIA value counts as none.<progress>or<meter>in the HTML namespace with avalueattribute reads throughHTMLProgressElement.prototype/HTMLMeterElement.prototype's built-in getter. A customized built-in (<progress is>) that overridesvaluenever runs, an element adopted from another frame still reads, and each browser parses the attribute its own way (Firefox readsvalue="70%"as0, Chromium as70). This replaces feat(web): read range widgets in toHaveValue #2061's hand-written attribute parser, as the last review asked.sliderorspinbuttonwith no value reads'', as before. Any other widget with none (an indeterminate<progress>, a<meter>with novalueattribute, a strayvalueattribute on adiv, a<progress>inside<svg>) has no value and fails withno value (not a form control).read-semantics.ts:1779), so they read as on main.rangeValue: true). The tree projection keepsrangeValue: false, so model input, replay cache evidence, and committed recordings do not change. Main'stoBeEmptyfieldemptyStatesits beside it; webtoBeEmptyreadsemptyOf, notvalue, so a valued slider is still empty, as in Playwright.reference/expect.mdx,reference/screen.mdx, the Detox guide (an Android text view whose value repeats its label usestoHaveText), and thewriting-testsskill line. Changeset:@e2e-dev/webpatch.Trust boundary: the reader runs in the page's main world. A page that redefines
HTMLProgressElement.prototype.valueitself is read through, the same asHTMLInputElement.prototype.valueis for inputs on main.Issue
Part of #1855 (
expect(locator).toHaveValue('On')). Replaces #2061.Verified
Ran it locally: yes
packages/e2e/tests/integration/to-have-value-widgets.test.tsruns the built CLI against a real Chromium page: every range role,aria-valuetextoveraria-valuenow, blank values, the native clamps, the refused cases, a throwing customized built-in next to an unrelatedgetByLabel('Email', { exact: true }), and controls adopted from another frame. Passes. Removing the HTML-namespace check fails it withIllegal invocation.web({ browser: 'firefox' }), comparinginputValue()with the page's owndocument.querySelector('progress').value:<progress>.valuevalue="70%" max="100"0700value="5 " max="10"050value="20" max="10"101010Chromium reads
70,5,10on both. WebKit not run.@e2e-dev/webread-node-checked.test.tsandcrosscheck.test.ts, mobilelocate.test.ts, e2escripted-matchers,scripted-reads, andweb-platformpass.pnpm checkpasses.Checklist
pnpm changeset) for any change to a published package, or the change is testbed, docs, or CI only.!, the changeset body names what breaks and what replaces it, and the deprecation warning landed a window earlier (stability policy in CONTRIBUTING.md).docs/**/*.mdxpage for the behavior, andskills/e2e/if the skill describes it..d.tsreviewed,tests/types/sdk-types.tsupdated; wire change edits the schema and both fixtures.e2e/engine): changesets fore2e,@e2e-dev/web, and@e2e-dev/mobile.Co-authored-by: Asheesh Kumar asheeshkumarklg712@gmail.com
Takeover and follow-up by Claude Opus 5.5 (
claude-opus-5-5) in Claude Code on T3 Code.