feat(e2e)!: inputValue and isChecked throw on the wrong element, uncheck clicks ARIA radios
Merged
OK
12d ago+126+126+012345678901234567890123456789-36-36-01234567890123456789
Follows the Playwright gaps plan: two items, both decided "match Playwright".
inputValue()on a node with no value (a heading, a button) throwsACTION_FAILEDwith Playwright's message, instead of"". Same ruletoHaveValuealready uses (isValueControlinpackages/e2e/src/internal/roles.ts): a value role with no value reported still reads"", since a device engine omits an empty value.isChecked()on a node with no checked state throwsACTION_FAILED("Not a checkbox or radio button"), instead offalse. Checkable means a reported state or one of Playwright'skAriaCheckedRoles(checkbox,menuitemcheckbox,option,radio,switch,menuitemradio,treeitem), so an ARIA switch withoutaria-checkedstill readsfalse.uncheck()on an ARIArole=radioclicks it, like Playwright. Only a native<input type=radio>refuses, with the same message as before. An ARIA radio whose click leaves it checked fails at the deadline with a hint about the radio group.ACTION_FAILEDbecause that is whatcheck()on a wrong element already gives.- Breaking, so the changeset is
minorwith**Breaking:**. Docs updated:reference/screen.mdx,reference/errors.mdx,skills/e2ereads paragraph, and inmigrate/playwright.mdx(on top of #1545) thecheck()/uncheck(),inputValue(),isChecked()rows and thetoBeCheckednote.
await screen.getByRole('heading', { level: 1 }).inputValue(); // ACTION_FAILED: Node is not an <input>, <textarea> or <select> element
await screen.getByRole('button', 'Save').isChecked(); // ACTION_FAILED: Not a checkbox or radio button
Marks removed (4 fail): check.e2e.ts "should uncheck radio by aria role", "should uncheck the box by aria role"; locator-convenience.e2e.ts "inputValue should work", "isChecked should work".
Callers checked: no agent, MCP, or engine code calls these reads; benchmarks read textbox/switch/checkbox nodes; two integration/unit tests that pinned ""/false on a heading/listitem now assert the throw.
Left as is, on purpose:
toBeCheckedstays lenient (.not.toBeChecked()passes on a button). Not in scope; the migrate guide says so.- On a
<label>, both reads now throw where Playwright reads the labeled control (before: a wrongfalse/""). Listed asmissingin the migrate guide. - A custom-drawn iOS field reported as
otherwith no value throws oninputValue(), astoHaveValuealready does there.
Verified
Ran it locally: yes
- testbed,
node node_modules/e2e/dist/cli/bin.js run --tag playwright: 504 passed, 5 skipped, exit 0 (on main after #1546 and #1549). The 4 unmarked tests pass, "should throw when trying to uncheck radio button" still passes. - Probe test on the testbed (not committed), built CLI:
label checkbox isChecked ERR ACTION_FAILED Not a checkbox or radio button: locator("#l1")
label input inputValue ERR ACTION_FAILED Node is not an <input>, <textarea> or <select> element: locator("#l2")
editable inputValue "hello"
option inputValue "x"
option isChecked false
switch isChecked false