From 95cb7e705802d9f03df2d09dc157931f3341b5d1 Mon Sep 17 00:00:00 2001 From: Samanyu Das Date: Sun, 25 Oct 2026 03:50:48 +1030 Subject: [PATCH 01/18] fix(web): check a radio or checkbox through its own label when the label covers it Element Plus hides the native input under its label's styled spans or gives it no box, so Playwright's hit-target check refused it. check, uncheck, and tap now click the label at the input's point when the element at that point is the label's own content, or the input's first label with a box when the input has none; anything else on top, a disabled input, an input on top itself, or a boxless input whose labels are all hidden is clicked as before. One in-page read decides whether a label stands in, so a tap on anything else pays that read and keeps locator.click, under one deadline. A locator that never appears still fails NOT_ACTIONABLE within one timeout. Fixes #1276 Co-Authored-By: Claude Fable 5.1 --- .changeset/check-through-label.md | 5 + docs/reference/screen.mdx | 5 + packages/web/src/actions.ts | 85 +++++++++++++- .../tests/integration/check-actions.test.ts | 106 ++++++++++++++++++ 4 files changed, 199 insertions(+), 2 deletions(-) create mode 100644 .changeset/check-through-label.md diff --git a/.changeset/check-through-label.md b/.changeset/check-through-label.md new file mode 100644 index 0000000000..593e095703 --- /dev/null +++ b/.changeset/check-through-label.md @@ -0,0 +1,5 @@ +--- +"@e2e-dev/web": patch +--- + +`check`, `uncheck`, and `tap` reach a native checkbox or radio that its own label covers, or that has no box of its own, as Element Plus draws its radio buttons, radios, and checkboxes, by clicking the label at the control's point; a control covered by anything else still fails `ACTION_FAILED`. diff --git a/docs/reference/screen.mdx b/docs/reference/screen.mdx index ca0dde8aee..d848e121b9 100644 --- a/docs/reference/screen.mdx +++ b/docs/reference/screen.mdx @@ -754,6 +754,11 @@ check(options?: ActionOptions): Promise; await screen.getByRole('checkbox', 'Remember me').check(); ``` +On the web engine, a native checkbox or radio that its own label covers +(Element Plus hides the input under the label's styled spans), or that has +no box of its own, is clicked through that label, by `check`, `uncheck`, and +`tap`. A control covered by anything else still fails `ACTION_FAILED`. + #### `uncheck` ```ts diff --git a/packages/web/src/actions.ts b/packages/web/src/actions.ts index dff2723d75..f7181fd29c 100644 --- a/packages/web/src/actions.ts +++ b/packages/web/src/actions.ts @@ -60,7 +60,7 @@ async function setChecked(target: ActionTarget, checked: boolean, operation: Con retryable: false, }); } - await element.click({ timeout: remaining() }); + await clickControl({ kind: 'element', element }, { timeout: remaining() }); const unchanged = (detail = ''): EngineError => new EngineError('NOT_ACTIONABLE', `${verb} clicked the control but its checked state did not change${detail}`, { retryable: false, @@ -88,6 +88,87 @@ async function setChecked(target: ActionTarget, checked: boolean, operation: Con } } +/** + * The label a click on a native checkbox or radio goes through instead of + * the control itself. Without `position` Playwright clicks the label's + * centre, which may be a link elsewhere in the label. + */ +interface StandIn { + labelIndex: number; + position?: { x: number; y: number }; +} + +/** + * Runs in the page. A component library (Element Plus) hides a native + * checkbox or radio under its label's styled spans with `z-index: -1`, or + * gives it no box at all, so Playwright refuses the input itself (` + * intercepts pointer events`, `element is not visible`) though a user's click + * there reaches it through the label. + */ +function pickStandIn(node: Element): StandIn | null { + if (!(node instanceof HTMLInputElement) || (node.type !== 'checkbox' && node.type !== 'radio') || node.disabled) { + return null; + } + const labels = [...(node.labels ?? [])]; + if (labels.length === 0) return null; + node.scrollIntoView({ block: 'nearest', inline: 'nearest' }); + const box = node.getBoundingClientRect(); + const hasBox = ({ width, height }: DOMRect): boolean => width > 0 && height > 0; + if (!hasBox(box)) { + const index = labels.findIndex((label) => hasBox(label.getBoundingClientRect())); + return index === -1 ? null : { labelIndex: index }; + } + const root = node.getRootNode(); + if (!(root instanceof Document) && !(root instanceof ShadowRoot)) return null; + const hit = root.elementFromPoint(box.left + box.width / 2, box.top + box.height / 2); + if (hit === null || hit === node) return null; + for (const [index, label] of labels.entries()) { + if (!label.contains(hit)) continue; + const outer = label.getBoundingClientRect(); + const x = box.left + box.width / 2 - outer.left; + const y = box.top + box.height / 2 - outer.top; + const inside = x >= 0 && y >= 0 && x <= outer.width && y <= outer.height; + return inside ? { labelIndex: index, position: { x, y } } : { labelIndex: index }; + } + return null; +} + +/** + * Clicks a control with Playwright's actionability checks, through its own + * label when `pickStandIn` names one. The checks then run on the label: its + * own content passes, anything else on top, such as a modal, still fails + * NOT_ACTIONABLE. + */ +async function clickControl( + target: ActionTarget, + options: { timeout: number; modifiers?: KeyModifier[] }, +): Promise { + const deadline = new Deadline(options.timeout); + const remaining = (): number => Math.max(1, deadline.remaining()); + const standIn = + target.kind === 'locator' + ? await target.locator.evaluate(pickStandIn, undefined, { timeout: options.timeout }) + : await target.element.evaluate(pickStandIn); + const labelAt = (node: Element, index: number): Element | null => + node instanceof HTMLInputElement ? (node.labels?.[index] ?? null) : null; + const label = + standIn === null + ? null + : target.kind === 'locator' + ? (await target.locator.evaluateHandle(labelAt, standIn.labelIndex)).asElement() + : (await target.element.evaluateHandle(labelAt, standIn.labelIndex)).asElement(); + if (standIn === null || label === null) { + await asActionable(target).click({ ...options, timeout: remaining() }); + return; + } + const { position } = standIn; + try { + await label.click({ ...options, timeout: remaining(), ...(position === undefined ? {} : { position }) }); + } finally { + void label.dispose().catch(() => undefined); + } +} + /** Whether a checkable element is a radio, which a click can select but never clear. */ function isRadio(element: ElementHandle): Promise { return element.evaluate( @@ -110,7 +191,7 @@ export async function dispatchLocatorAction( const locator = asActionable(target); switch (action.kind) { case 'tap': - await locator.click({ timeout, ...heldKeys(action) }); + await clickControl(target, { timeout, ...heldKeys(action) }); return; case 'doubleTap': await locator.dblclick({ timeout, ...heldKeys(action) }); diff --git a/packages/web/tests/integration/check-actions.test.ts b/packages/web/tests/integration/check-actions.test.ts index 85cbba9ea5..4e22048ace 100644 --- a/packages/web/tests/integration/check-actions.test.ts +++ b/packages/web/tests/integration/check-actions.test.ts @@ -171,3 +171,109 @@ describe('a control gone before the click', () => { expect(await perform(target, { kind: 'check' })).toMatchObject({ code: 'NODE_STALE', retryable: true }); }); }); + +const ELEMENT_PLUS_CSS = ` +.el-radio-button{outline:none;display:inline-block;position:relative} +.el-radio-button__original-radio{opacity:0;z-index:-1;outline:none;position:absolute} +.el-radio-button__inner{white-space:nowrap;vertical-align:middle;background:#fff;border:1px solid #dcdfe6;line-height:1;cursor:pointer;display:inline-block;position:relative;padding:8px 15px} +.el-checkbox{cursor:pointer;display:inline-flex;align-items:center;position:relative} +.el-checkbox__input{white-space:nowrap;cursor:pointer;outline:none;display:inline-flex;position:relative} +.el-checkbox__original{opacity:0;z-index:-1;outline:none;width:0;height:0;margin:0;position:absolute} +.el-checkbox__inner{display:inline-block;position:relative;border:1px solid #dcdfe6;width:14px;height:14px;background:#fff;z-index:1} +.el-radio{cursor:pointer;display:inline-flex;align-items:center;position:relative} +.el-radio__input{white-space:nowrap;cursor:pointer;outline:none;display:inline-flex;position:relative} +.el-radio__original{opacity:0;z-index:-1;outline:none;margin:0;position:absolute;top:0;bottom:0;left:0;right:0} +.el-radio__inner{border:1px solid #dcdfe6;border-radius:100%;width:14px;height:14px;background:#fff;position:relative;display:inline-block} +.modal{position:fixed;inset:0;background:rgba(0,0,0,.4);z-index:10} +`; + +const ELEMENT_PLUS_CONTROLS = ` + + + + +`; + +const ELEMENT_PLUS_PAGE = `${ELEMENT_PLUS_CONTROLS}`; + +const ELEMENT_PLUS_CASES = [ + ['radio-button', '#install'], + ['checkbox', '#agree'], + ['radio', '#large'], +] as const; + +describe.each(KINDS)('a control its own label covers, through the %s target', (kind) => { + it.each(ELEMENT_PLUS_CASES)('checks an Element Plus %s', async (_, selector) => { + await page.setContent(ELEMENT_PLUS_PAGE); + expect(await perform(await targetOf(kind, selector), { kind: 'check' })).toBeUndefined(); + expect(await page.isChecked(selector)).toBe(true); + }); + + it.each(ELEMENT_PLUS_CASES)('taps an Element Plus %s', async (_, selector) => { + await page.setContent(ELEMENT_PLUS_PAGE); + expect(await perform(await targetOf(kind, selector), { kind: 'tap' })).toBeUndefined(); + expect(await page.isChecked(selector)).toBe(true); + }); + + it.each(ELEMENT_PLUS_CASES)('still refuses an Element Plus %s under a modal', async (_, selector) => { + await page.setContent(`${ELEMENT_PLUS_PAGE}`); + for (const action of [{ kind: 'check' }, { kind: 'tap' }] as const) { + expect(await perform(await targetOf(kind, selector), action)).toMatchObject({ code: 'NOT_ACTIONABLE' }); + expect(await page.isChecked(selector)).toBe(false); + } + }); + + it('checks a boxless checkbox through its first visible label, past a hidden one', async () => { + await page.setContent(` + + + `); + expect(await perform(await targetOf(kind, '#c'), { kind: 'check' })).toBeUndefined(); + expect(await page.isChecked('#c')).toBe(true); + }); + + it('still refuses a boxless checkbox whose every label is hidden', async () => { + await page.setContent(` + + `); + expect(await perform(await targetOf(kind, '#c'), { kind: 'check' })).toMatchObject({ code: 'NOT_ACTIONABLE' }); + expect(await page.isChecked('#c')).toBe(false); + }); + + it('still refuses a disabled Element Plus radio-button', async () => { + await page.setContent(ELEMENT_PLUS_PAGE.replace('id="install"', 'id="install" disabled')); + for (const action of [{ kind: 'check' }, { kind: 'tap' }] as const) { + expect(await perform(await targetOf(kind, '#install'), action)).toMatchObject({ code: 'NOT_ACTIONABLE' }); + expect(await page.isChecked('#install')).toBe(false); + } + }); + + it('checks an Element Plus radio-button inside a shadow root', async () => { + await page.setContent(`
`); + expect(await perform(await targetOf(kind, '#install'), { kind: 'check' })).toBeUndefined(); + expect(await page.isChecked('#install')).toBe(true); + }); +}); + +describe('a tap on a locator that never appears', () => { + it('fails NOT_ACTIONABLE within one deadline, as a plain click does', async () => { + await page.setContent('

Nothing to tap

'); + const started = Date.now(); + const error = await perform({ kind: 'locator', locator: page.locator('#missing') }, { kind: 'tap' }); + expect(Date.now() - started).toBeLessThan(3500); + expect(error).toMatchObject({ code: 'NOT_ACTIONABLE', retryable: false }); + expect(error?.message).toMatch(/^tap did not become actionable in time: .*Timeout 2000ms exceeded/); + expect(error?.message).toContain("waiting for locator('#missing')"); + }); +}); + +describe('a control its own label covers, inside a frame', () => { + it('checks an Element Plus radio-button', async () => { + await page.setContent(`

Outer

`); + const locator = page.frameLocator('iframe').locator('#install'); + expect(await perform({ kind: 'locator', locator }, { kind: 'check' })).toBeUndefined(); + expect(await locator.isChecked()).toBe(true); + }); +}); From c88fd0b0a9cd99a5f1f8c1b4de6250d19cae9e79 Mon Sep 17 00:00:00 2001 From: Samanyu Das Date: Sun, 25 Oct 2026 04:26:46 +1030 Subject: [PATCH 02/18] fix(web): skip the label stand-in for disabled fieldsets, hidden labels, and links over the input A control a disabled fieldset holds is refused by :disabled, not only the attribute. A boxless control picks a label that is rendered (checkVisibility), since visibility: hidden keeps its box. No label stands in when the element at the click point, the input's centre or a boxless label's centre, is a link, button, or other interactive descendant of the label: the click would press that instead, and a tap could follow a link. The locator's label resolution runs under the action's remaining deadline. Docs: uncheck reaches a checkbox only, the boxless case needs a visible label, and a link or button in the label still fails. Co-Authored-By: Claude Fable 5.1 --- docs/reference/screen.mdx | 6 ++- packages/web/src/actions.ts | 38 ++++++++++----- .../tests/integration/check-actions.test.ts | 48 +++++++++++++++++++ 3 files changed, 77 insertions(+), 15 deletions(-) diff --git a/docs/reference/screen.mdx b/docs/reference/screen.mdx index d848e121b9..1ca3fb07d4 100644 --- a/docs/reference/screen.mdx +++ b/docs/reference/screen.mdx @@ -756,8 +756,10 @@ await screen.getByRole('checkbox', 'Remember me').check(); On the web engine, a native checkbox or radio that its own label covers (Element Plus hides the input under the label's styled spans), or that has -no box of its own, is clicked through that label, by `check`, `uncheck`, and -`tap`. A control covered by anything else still fails `ACTION_FAILED`. +no box of its own and a visible label, is clicked through that label by +`check` and `tap`, and by `uncheck` for a checkbox. A control covered by +anything else, a link or button in its label included, still fails +`ACTION_FAILED`. #### `uncheck` diff --git a/packages/web/src/actions.ts b/packages/web/src/actions.ts index f7181fd29c..499452fb1c 100644 --- a/packages/web/src/actions.ts +++ b/packages/web/src/actions.ts @@ -90,8 +90,8 @@ async function setChecked(target: ActionTarget, checked: boolean, operation: Con /** * The label a click on a native checkbox or radio goes through instead of - * the control itself. Without `position` Playwright clicks the label's - * centre, which may be a link elsewhere in the label. + * the control itself, at the control's point when it has one, else at the + * label's centre. */ interface StandIn { labelIndex: number; @@ -106,24 +106,37 @@ interface StandIn { * there reaches it through the label. */ function pickStandIn(node: Element): StandIn | null { - if (!(node instanceof HTMLInputElement) || (node.type !== 'checkbox' && node.type !== 'radio') || node.disabled) { + if (!(node instanceof HTMLInputElement) || (node.type !== 'checkbox' && node.type !== 'radio') || node.matches(':disabled')) { return null; } const labels = [...(node.labels ?? [])]; - if (labels.length === 0) return null; + const root = node.getRootNode(); + if (labels.length === 0 || (!(root instanceof Document) && !(root instanceof ShadowRoot))) return null; + const INTERACTIVE = 'a,button,input,select,textarea,summary,[contenteditable],[role="button"],[role="link"]'; + const hasBox = ({ width, height }: DOMRect): boolean => width > 0 && height > 0; + const centre = ({ left, top, width, height }: DOMRect): [number, number] => [left + width / 2, top + height / 2]; + const pressesInteractive = (label: HTMLLabelElement, hit: Element | null): boolean => { + const interactive = hit?.closest(INTERACTIVE) ?? null; + return interactive !== null && label.contains(interactive); + }; node.scrollIntoView({ block: 'nearest', inline: 'nearest' }); const box = node.getBoundingClientRect(); - const hasBox = ({ width, height }: DOMRect): boolean => width > 0 && height > 0; if (!hasBox(box)) { - const index = labels.findIndex((label) => hasBox(label.getBoundingClientRect())); + const index = labels.findIndex((label) => { + const outer = label.getBoundingClientRect(); + return ( + hasBox(outer) && + label.checkVisibility({ visibilityProperty: true }) && + !pressesInteractive(label, root.elementFromPoint(...centre(outer))) + ); + }); return index === -1 ? null : { labelIndex: index }; } - const root = node.getRootNode(); - if (!(root instanceof Document) && !(root instanceof ShadowRoot)) return null; - const hit = root.elementFromPoint(box.left + box.width / 2, box.top + box.height / 2); + const hit = root.elementFromPoint(...centre(box)); if (hit === null || hit === node) return null; for (const [index, label] of labels.entries()) { if (!label.contains(hit)) continue; + if (pressesInteractive(label, hit)) return null; const outer = label.getBoundingClientRect(); const x = box.left + box.width / 2 - outer.left; const y = box.top + box.height / 2 - outer.top; @@ -135,9 +148,8 @@ function pickStandIn(node: Element): StandIn | null { /** * Clicks a control with Playwright's actionability checks, through its own - * label when `pickStandIn` names one. The checks then run on the label: its - * own content passes, anything else on top, such as a modal, still fails - * NOT_ACTIONABLE. + * label when `pickStandIn` names one. The checks then run on the label, so + * anything else on top, such as a modal, still fails NOT_ACTIONABLE. */ async function clickControl( target: ActionTarget, @@ -155,7 +167,7 @@ async function clickControl( standIn === null ? null : target.kind === 'locator' - ? (await target.locator.evaluateHandle(labelAt, standIn.labelIndex)).asElement() + ? (await target.locator.evaluateHandle(labelAt, standIn.labelIndex, { timeout: remaining() })).asElement() : (await target.element.evaluateHandle(labelAt, standIn.labelIndex)).asElement(); if (standIn === null || label === null) { await asActionable(target).click({ ...options, timeout: remaining() }); diff --git a/packages/web/tests/integration/check-actions.test.ts b/packages/web/tests/integration/check-actions.test.ts index 4e22048ace..1902a1da6b 100644 --- a/packages/web/tests/integration/check-actions.test.ts +++ b/packages/web/tests/integration/check-actions.test.ts @@ -232,6 +232,54 @@ describe.each(KINDS)('a control its own label covers, through the %s target', (k expect(await page.isChecked('#c')).toBe(true); }); + it('checks a boxless checkbox past a label hidden by visibility, which keeps its box', async () => { + await page.setContent(` + + + `); + expect(await perform(await targetOf(kind, '#c'), { kind: 'check' })).toBeUndefined(); + expect(await page.isChecked('#c')).toBe(true); + }); + + it('still refuses a radio under a link in its own label, and follows no link', async () => { + await page.setContent(` + `); + for (const action of [{ kind: 'check' }, { kind: 'tap' }] as const) { + expect(await perform(await targetOf(kind, '#install'), action)).toMatchObject({ + code: 'NOT_ACTIONABLE', + message: expect.stringContaining('intercepts pointer events'), + }); + expect(await page.isChecked('#install')).toBe(false); + expect(page.url()).not.toContain('#went'); + } + }); + + it('still refuses a boxless checkbox whose visible label has a link at its centre', async () => { + await page.setContent(` + + `); + for (const action of [{ kind: 'check' }, { kind: 'tap' }] as const) { + expect(await perform(await targetOf(kind, '#c'), action)).toMatchObject({ + code: 'NOT_ACTIONABLE', + message: expect.stringContaining('not visible'), + }); + expect(await page.isChecked('#c')).toBe(false); + expect(page.url()).not.toContain('#went'); + } + }); + + it('still refuses an Element Plus radio-button a disabled fieldset holds', async () => { + await page.setContent(`
${ELEMENT_PLUS_CONTROLS}
`); + for (const action of [{ kind: 'check' }, { kind: 'tap' }] as const) { + expect(await perform(await targetOf(kind, '#install'), action)).toMatchObject({ + code: 'NOT_ACTIONABLE', + message: expect.stringContaining('not enabled'), + }); + expect(await page.isChecked('#install')).toBe(false); + } + }); + it('still refuses a boxless checkbox whose every label is hidden', async () => { await page.setContent(` From dc700e8bcb52c02f41f7e29bf03473d19b3d9ff2 Mon Sep 17 00:00:00 2001 From: Samanyu Das Date: Mon, 26 Oct 2026 11:48:02 +1030 Subject: [PATCH 03/18] fix(web): choose the label stand-in past loading masks and wait for an unrendered control The stand-in was decided once from elementFromPoint, so a loading mask on top, or a dialog not open yet, sent the click to the input, which its label then covered until the deadline. The choice now reads the stack at the input's point past anything outside the control and its labels, so Playwright's checks on the label wait the mask out, and is polled while nothing of the control is rendered, failing NOT_ACTIONABLE at the deadline. One evaluateHandle returns the label itself, so the index and the second resolve are gone. A point outside the label's box clicks the input as before, and a tap on anything else returns before scrolling. Co-Authored-By: Claude Opus 5.5 --- .changeset/check-through-label.md | 2 +- docs/reference/screen.mdx | 9 +- packages/web/src/actions.ts | 133 +++++++++++------- .../tests/integration/check-actions.test.ts | 43 +++++- 4 files changed, 124 insertions(+), 63 deletions(-) diff --git a/.changeset/check-through-label.md b/.changeset/check-through-label.md index 593e095703..7a5689e801 100644 --- a/.changeset/check-through-label.md +++ b/.changeset/check-through-label.md @@ -2,4 +2,4 @@ "@e2e-dev/web": patch --- -`check`, `uncheck`, and `tap` reach a native checkbox or radio that its own label covers, or that has no box of its own, as Element Plus draws its radio buttons, radios, and checkboxes, by clicking the label at the control's point; a control covered by anything else still fails `ACTION_FAILED`. +`check`, `uncheck`, and `tap` click a checkbox or radio hidden under its own label (as in Element Plus) through that label. Anything else covering it still fails `ACTION_FAILED`. diff --git a/docs/reference/screen.mdx b/docs/reference/screen.mdx index 1ca3fb07d4..8c7ce59ee7 100644 --- a/docs/reference/screen.mdx +++ b/docs/reference/screen.mdx @@ -754,12 +754,9 @@ check(options?: ActionOptions): Promise; await screen.getByRole('checkbox', 'Remember me').check(); ``` -On the web engine, a native checkbox or radio that its own label covers -(Element Plus hides the input under the label's styled spans), or that has -no box of its own and a visible label, is clicked through that label by -`check` and `tap`, and by `uncheck` for a checkbox. A control covered by -anything else, a link or button in its label included, still fails -`ACTION_FAILED`. +On the web engine, a checkbox or radio hidden under its own label (as in +Element Plus) is clicked through that label. Anything else covering it still +fails `ACTION_FAILED`. #### `uncheck` diff --git a/packages/web/src/actions.ts b/packages/web/src/actions.ts index 499452fb1c..fd49be12ef 100644 --- a/packages/web/src/actions.ts +++ b/packages/web/src/actions.ts @@ -60,7 +60,7 @@ async function setChecked(target: ActionTarget, checked: boolean, operation: Con retryable: false, }); } - await clickControl({ kind: 'element', element }, { timeout: remaining() }); + await clickControl({ kind: 'element', element }, verb, { timeout: remaining(), signal: operation.signal }); const unchanged = (detail = ''): EngineError => new EngineError('NOT_ACTIONABLE', `${verb} clicked the control but its checked state did not change${detail}`, { retryable: false, @@ -89,23 +89,23 @@ async function setChecked(target: ActionTarget, checked: boolean, operation: Con } /** - * The label a click on a native checkbox or radio goes through instead of - * the control itself, at the control's point when it has one, else at the - * label's centre. + * What the page throws while a checkbox or radio and every one of its labels + * are unrendered, so a click could reach none of them yet. */ -interface StandIn { - labelIndex: number; - position?: { x: number; y: number }; -} +const UNRENDERED = 'the control and its labels are not visible'; /** * Runs in the page. A component library (Element Plus) hides a native * checkbox or radio under its label's styled spans with `z-index: -1`, or * gives it no box at all, so Playwright refuses the input itself (` * intercepts pointer events`, `element is not visible`) though a user's click - * there reaches it through the label. + * there reaches it through the label. Returns that label, or null to click the + * control itself. The choice reads the control and its labels only, past + * anything else on top (a loading mask, a modal): Playwright's checks on the + * label wait that out, or fail on it. Throws `UNRENDERED` while none of them + * is rendered (a dialog not open yet), since nothing tells the two apart then. */ -function pickStandIn(node: Element): StandIn | null { +function pickStandIn(node: Element, unrendered: string): HTMLLabelElement | null { if (!(node instanceof HTMLInputElement) || (node.type !== 'checkbox' && node.type !== 'radio') || node.matches(':disabled')) { return null; } @@ -115,67 +115,92 @@ function pickStandIn(node: Element): StandIn | null { const INTERACTIVE = 'a,button,input,select,textarea,summary,[contenteditable],[role="button"],[role="link"]'; const hasBox = ({ width, height }: DOMRect): boolean => width > 0 && height > 0; const centre = ({ left, top, width, height }: DOMRect): [number, number] => [left + width / 2, top + height / 2]; - const pressesInteractive = (label: HTMLLabelElement, hit: Element | null): boolean => { - const interactive = hit?.closest(INTERACTIVE) ?? null; - return interactive !== null && label.contains(interactive); - }; + const topmost = (x: number, y: number): Element | undefined => + root.elementsFromPoint(x, y).find((hit) => hit === node || labels.some((label) => label.contains(hit))); + const pressesInteractive = (label: HTMLLabelElement, hit: Element | undefined): boolean => + label.contains(hit?.closest(INTERACTIVE) ?? null); node.scrollIntoView({ block: 'nearest', inline: 'nearest' }); const box = node.getBoundingClientRect(); if (!hasBox(box)) { - const index = labels.findIndex((label) => { - const outer = label.getBoundingClientRect(); - return ( - hasBox(outer) && - label.checkVisibility({ visibilityProperty: true }) && - !pressesInteractive(label, root.elementFromPoint(...centre(outer))) - ); - }); - return index === -1 ? null : { labelIndex: index }; - } - const hit = root.elementFromPoint(...centre(box)); - if (hit === null || hit === node) return null; - for (const [index, label] of labels.entries()) { - if (!label.contains(hit)) continue; - if (pressesInteractive(label, hit)) return null; - const outer = label.getBoundingClientRect(); - const x = box.left + box.width / 2 - outer.left; - const y = box.top + box.height / 2 - outer.top; - const inside = x >= 0 && y >= 0 && x <= outer.width && y <= outer.height; - return inside ? { labelIndex: index, position: { x, y } } : { labelIndex: index }; + const shown = labels.filter((label) => hasBox(label.getBoundingClientRect()) && label.checkVisibility({ visibilityProperty: true })); + if (shown.length === 0) throw new Error(unrendered); + return ( + shown.find((label) => { + label.scrollIntoView({ block: 'nearest', inline: 'nearest' }); + return !pressesInteractive(label, topmost(...centre(label.getBoundingClientRect()))); + }) ?? null + ); } - return null; + const [x, y] = centre(box); + const hit = topmost(x, y); + if (hit === undefined) throw new Error(unrendered); + const label = labels.find((own) => own.contains(hit)); + if (label === undefined || pressesInteractive(label, hit)) return null; + const outer = label.getBoundingClientRect(); + return x >= outer.left && x <= outer.right && y >= outer.top && y <= outer.bottom ? label : null; +} + +/** + * Runs in the page: where a click on the label lands, the centre of its + * control relative to the label, or none for a control with no box, which + * takes the label's centre. + */ +function controlPoint(label: HTMLLabelElement): { x: number; y: number } | null { + const box = label.control?.getBoundingClientRect(); + if (box === undefined || box.width === 0 || box.height === 0) return null; + const outer = label.getBoundingClientRect(); + return { x: box.left + box.width / 2 - outer.left, y: box.top + box.height / 2 - outer.top }; } /** * Clicks a control with Playwright's actionability checks, through its own * label when `pickStandIn` names one. The checks then run on the label, so - * anything else on top, such as a modal, still fails NOT_ACTIONABLE. + * anything else on top, such as a modal, still fails NOT_ACTIONABLE. The + * choice is read again until the control or a label renders, within the + * deadline. */ async function clickControl( target: ActionTarget, - options: { timeout: number; modifiers?: KeyModifier[] }, + verb: 'tap' | 'check' | 'uncheck', + options: { timeout: number; signal: AbortSignal; modifiers?: KeyModifier[] }, ): Promise { + const { signal, ...click } = options; const deadline = new Deadline(options.timeout); const remaining = (): number => Math.max(1, deadline.remaining()); - const standIn = - target.kind === 'locator' - ? await target.locator.evaluate(pickStandIn, undefined, { timeout: options.timeout }) - : await target.element.evaluate(pickStandIn); - const labelAt = (node: Element, index: number): Element | null => - node instanceof HTMLInputElement ? (node.labels?.[index] ?? null) : null; - const label = - standIn === null - ? null - : target.kind === 'locator' - ? (await target.locator.evaluateHandle(labelAt, standIn.labelIndex, { timeout: remaining() })).asElement() - : (await target.element.evaluateHandle(labelAt, standIn.labelIndex)).asElement(); - if (standIn === null || label === null) { - await asActionable(target).click({ ...options, timeout: remaining() }); + // Set inside the poll; the assertion keeps TypeScript from narrowing it to null here. + let label = null as ElementHandle | null; + let firstRead = true; + await pollCondition({ + deadline, + signal, + negated: false, + evaluate: async () => { + const first = firstRead; + firstRead = false; + try { + const handle = + target.kind === 'locator' + ? await target.locator.evaluateHandle(pickStandIn, UNRENDERED, { timeout: remaining() }) + : await target.element.evaluateHandle(pickStandIn, UNRENDERED); + label = handle.asElement(); + return true; + } catch (cause) { + if (message(cause).includes(UNRENDERED)) return undefined; + // A read after one that found nothing rendered times out only at the deadline, which ends the poll. + if (!first && isPwTimeout(cause)) return undefined; + throw cause; + } + }, + onTimeout: () => + new EngineError('NOT_ACTIONABLE', `${verb} did not become actionable in time: ${UNRENDERED}`, { retryable: false }), + }); + if (label === null) { + await asActionable(target).click({ ...click, timeout: remaining() }); return; } - const { position } = standIn; try { - await label.click({ ...options, timeout: remaining(), ...(position === undefined ? {} : { position }) }); + const position = await label.evaluate(controlPoint); + await label.click({ ...click, timeout: remaining(), ...(position === null ? {} : { position }) }); } finally { void label.dispose().catch(() => undefined); } @@ -203,7 +228,7 @@ export async function dispatchLocatorAction( const locator = asActionable(target); switch (action.kind) { case 'tap': - await clickControl(target, { timeout, ...heldKeys(action) }); + await clickControl(target, 'tap', { timeout, signal: operation.signal, ...heldKeys(action) }); return; case 'doubleTap': await locator.dblclick({ timeout, ...heldKeys(action) }); diff --git a/packages/web/tests/integration/check-actions.test.ts b/packages/web/tests/integration/check-actions.test.ts index 1902a1da6b..87ecbff56d 100644 --- a/packages/web/tests/integration/check-actions.test.ts +++ b/packages/web/tests/integration/check-actions.test.ts @@ -223,6 +223,40 @@ describe.each(KINDS)('a control its own label covers, through the %s target', (k } }); + it.each(ELEMENT_PLUS_CASES)('waits out a loading mask over an Element Plus %s', async (_, selector) => { + for (const action of [{ kind: 'check' }, { kind: 'tap' }] as const) { + await page.setContent(`${ELEMENT_PLUS_PAGE} + `); + expect(await perform(await targetOf(kind, selector), action)).toBeUndefined(); + expect(await page.isChecked(selector)).toBe(true); + } + }); + + it.each(ELEMENT_PLUS_CASES)('waits for an Element Plus %s in a dialog that opens later', async (_, selector) => { + for (const display of ['display:none', 'visibility:hidden']) { + for (const action of [{ kind: 'check' }, { kind: 'tap' }] as const) { + await page.setContent(`
${ELEMENT_PLUS_CONTROLS}
+ `); + expect(await perform(await targetOf(kind, selector), action)).toBeUndefined(); + expect(await page.isChecked(selector)).toBe(true); + } + } + }); + + it('still refuses a radio whose label covers it from outside the label box', async () => { + await page.setContent(` + `); + for (const action of [{ kind: 'check' }, { kind: 'tap' }] as const) { + expect(await perform(await targetOf(kind, '#r'), action)).toMatchObject({ + code: 'NOT_ACTIONABLE', + message: expect.stringContaining('intercepts pointer events'), + }); + expect(await page.isChecked('#r')).toBe(false); + } + }); + it('checks a boxless checkbox through its first visible label, past a hidden one', async () => { await page.setContent(` @@ -284,8 +318,13 @@ describe.each(KINDS)('a control its own label covers, through the %s target', (k await page.setContent(` `); - expect(await perform(await targetOf(kind, '#c'), { kind: 'check' })).toMatchObject({ code: 'NOT_ACTIONABLE' }); - expect(await page.isChecked('#c')).toBe(false); + for (const action of [{ kind: 'check' }, { kind: 'tap' }] as const) { + expect(await perform(await targetOf(kind, '#c'), action)).toMatchObject({ + code: 'NOT_ACTIONABLE', + message: `${action.kind} did not become actionable in time: the control and its labels are not visible`, + }); + expect(await page.isChecked('#c')).toBe(false); + } }); it('still refuses a disabled Element Plus radio-button', async () => { From 0c51c8410f0c2c7ee44d12dde8f95ebf2f0a6823 Mon Sep 17 00:00:00 2001 From: Samanyu Das Date: Mon, 26 Oct 2026 12:04:25 +1030 Subject: [PATCH 04/18] fix(web): click no control after a cancelled stand-in read, and dispose the null handle The surface abandons a cancelled or timed-out operation without stopping it, so a stand-in read still in flight went on to click. The signal is now checked right before both click paths. The handle `pickStandIn` returns for a control clicked as itself is disposed instead of living until the page navigates. Co-Authored-By: Claude Opus 5.5 --- packages/web/src/actions.ts | 4 ++++ .../tests/integration/check-actions.test.ts | 19 +++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/packages/web/src/actions.ts b/packages/web/src/actions.ts index fd49be12ef..e3595a2eff 100644 --- a/packages/web/src/actions.ts +++ b/packages/web/src/actions.ts @@ -183,6 +183,7 @@ async function clickControl( ? await target.locator.evaluateHandle(pickStandIn, UNRENDERED, { timeout: remaining() }) : await target.element.evaluateHandle(pickStandIn, UNRENDERED); label = handle.asElement(); + if (label === null) void handle.dispose().catch(() => undefined); return true; } catch (cause) { if (message(cause).includes(UNRENDERED)) return undefined; @@ -194,12 +195,15 @@ async function clickControl( onTimeout: () => new EngineError('NOT_ACTIONABLE', `${verb} did not become actionable in time: ${UNRENDERED}`, { retryable: false }), }); + // The operation abandons this call when cancelled; a read still in flight then must not lead to a click. if (label === null) { + signal.throwIfAborted(); await asActionable(target).click({ ...click, timeout: remaining() }); return; } try { const position = await label.evaluate(controlPoint); + signal.throwIfAborted(); await label.click({ ...click, timeout: remaining(), ...(position === null ? {} : { position }) }); } finally { void label.dispose().catch(() => undefined); diff --git a/packages/web/tests/integration/check-actions.test.ts b/packages/web/tests/integration/check-actions.test.ts index 87ecbff56d..dfbe69f0e8 100644 --- a/packages/web/tests/integration/check-actions.test.ts +++ b/packages/web/tests/integration/check-actions.test.ts @@ -364,3 +364,22 @@ describe('a control its own label covers, inside a frame', () => { expect(await locator.isChecked()).toBe(true); }); }); + +describe('an action cancelled while its stand-in read is in flight', () => { + it.each(KINDS)('clicks nothing through the %s target', async (kind) => { + for (const [selector, action] of [['#install', { kind: 'tap' }], ['#install', { kind: 'check' }], ['#plain', { kind: 'tap' }]] as const) { + await page.setContent(`${ELEMENT_PLUS_PAGE}`); + const target = await targetOf(kind, selector); + // Holds the page's main thread, so the read waits behind it until after the abort. + await page.evaluate(() => setTimeout(() => { const until = Date.now() + 400; while (Date.now() < until); }, 0)); + const controller = new AbortController(); + setTimeout(() => controller.abort(new Error('cancelled')), 100); + await expect( + dispatchLocatorAction(target, action, { timeoutMs: 2000, signal: controller.signal }, () => { + throw new Error('no second target'); + }), + ).rejects.toThrow('cancelled'); + expect(await page.isChecked(selector)).toBe(false); + } + }); +}); From 779130e08677961826041334a7add9567859d79c Mon Sep 17 00:00:00 2001 From: Samanyu Das Date: Tue, 27 Oct 2026 21:46:56 +1030 Subject: [PATCH 05/18] refactor(web): type the label stand-in as undefined instead of a null cast A `let` initialised to `null` narrows to `null`, and TypeScript does not see the assignment inside the poll callback, so the old code needed an `as` cast and a comment. Declared without an initialiser, the variable keeps its declared type after the poll. No behaviour change. Co-Authored-By: Claude Opus 5.5 --- packages/web/src/actions.ts | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/packages/web/src/actions.ts b/packages/web/src/actions.ts index e3595a2eff..c72c693ab5 100644 --- a/packages/web/src/actions.ts +++ b/packages/web/src/actions.ts @@ -167,8 +167,7 @@ async function clickControl( const { signal, ...click } = options; const deadline = new Deadline(options.timeout); const remaining = (): number => Math.max(1, deadline.remaining()); - // Set inside the poll; the assertion keeps TypeScript from narrowing it to null here. - let label = null as ElementHandle | null; + let label: ElementHandle | undefined; let firstRead = true; await pollCondition({ deadline, @@ -182,8 +181,8 @@ async function clickControl( target.kind === 'locator' ? await target.locator.evaluateHandle(pickStandIn, UNRENDERED, { timeout: remaining() }) : await target.element.evaluateHandle(pickStandIn, UNRENDERED); - label = handle.asElement(); - if (label === null) void handle.dispose().catch(() => undefined); + label = handle.asElement() ?? undefined; + if (label === undefined) void handle.dispose().catch(() => undefined); return true; } catch (cause) { if (message(cause).includes(UNRENDERED)) return undefined; @@ -196,7 +195,7 @@ async function clickControl( new EngineError('NOT_ACTIONABLE', `${verb} did not become actionable in time: ${UNRENDERED}`, { retryable: false }), }); // The operation abandons this call when cancelled; a read still in flight then must not lead to a click. - if (label === null) { + if (label === undefined) { signal.throwIfAborted(); await asActionable(target).click({ ...click, timeout: remaining() }); return; From 2e0883dea58da4b15536959a8cf768f81d4a9dc9 Mon Sep 17 00:00:00 2001 From: Samanyu Das Date: Tue, 27 Oct 2026 21:46:56 +1030 Subject: [PATCH 06/18] test(web): give the label refusal cases a 500ms deadline Each "still refuses" case waited out the 2s deadline twice (check, then tap). `perform` now takes a timeout, and those cases pass 500ms. The file drops from about 102s to 48s locally. Co-Authored-By: Claude Opus 5.5 --- .../tests/integration/check-actions.test.ts | 21 +++++++++++-------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/packages/web/tests/integration/check-actions.test.ts b/packages/web/tests/integration/check-actions.test.ts index dfbe69f0e8..6954e82f9e 100644 --- a/packages/web/tests/integration/check-actions.test.ts +++ b/packages/web/tests/integration/check-actions.test.ts @@ -55,10 +55,13 @@ async function targetOf(kind: (typeof KINDS)[number], selector: string): Promise return { kind, element }; } +/** A refusal waits out the whole deadline, so the cases that expect one take a short one. */ +const REFUSAL_TIMEOUT_MS = 500; + /** Performs one action and returns the contract error it failed with, classified as the engine reports it. */ -async function perform(target: ActionTarget, action: LocatorAction): Promise { +async function perform(target: ActionTarget, action: LocatorAction, timeoutMs = 2000): Promise { try { - await dispatchLocatorAction(target, action, { timeoutMs: 2000, signal: new AbortController().signal }, () => { + await dispatchLocatorAction(target, action, { timeoutMs, signal: new AbortController().signal }, () => { throw new Error('no second target'); }); return undefined; @@ -218,7 +221,7 @@ describe.each(KINDS)('a control its own label covers, through the %s target', (k it.each(ELEMENT_PLUS_CASES)('still refuses an Element Plus %s under a modal', async (_, selector) => { await page.setContent(`${ELEMENT_PLUS_PAGE}`); for (const action of [{ kind: 'check' }, { kind: 'tap' }] as const) { - expect(await perform(await targetOf(kind, selector), action)).toMatchObject({ code: 'NOT_ACTIONABLE' }); + expect(await perform(await targetOf(kind, selector), action, REFUSAL_TIMEOUT_MS)).toMatchObject({ code: 'NOT_ACTIONABLE' }); expect(await page.isChecked(selector)).toBe(false); } }); @@ -249,7 +252,7 @@ describe.each(KINDS)('a control its own label covers, through the %s target', (k style="position:absolute;left:200px;top:100px;opacity:0;z-index:-1">`); for (const action of [{ kind: 'check' }, { kind: 'tap' }] as const) { - expect(await perform(await targetOf(kind, '#r'), action)).toMatchObject({ + expect(await perform(await targetOf(kind, '#r'), action, REFUSAL_TIMEOUT_MS)).toMatchObject({ code: 'NOT_ACTIONABLE', message: expect.stringContaining('intercepts pointer events'), }); @@ -280,7 +283,7 @@ describe.each(KINDS)('a control its own label covers, through the %s target', (k `); for (const action of [{ kind: 'check' }, { kind: 'tap' }] as const) { - expect(await perform(await targetOf(kind, '#install'), action)).toMatchObject({ + expect(await perform(await targetOf(kind, '#install'), action, REFUSAL_TIMEOUT_MS)).toMatchObject({ code: 'NOT_ACTIONABLE', message: expect.stringContaining('intercepts pointer events'), }); @@ -294,7 +297,7 @@ describe.each(KINDS)('a control its own label covers, through the %s target', (k `); for (const action of [{ kind: 'check' }, { kind: 'tap' }] as const) { - expect(await perform(await targetOf(kind, '#c'), action)).toMatchObject({ + expect(await perform(await targetOf(kind, '#c'), action, REFUSAL_TIMEOUT_MS)).toMatchObject({ code: 'NOT_ACTIONABLE', message: expect.stringContaining('not visible'), }); @@ -306,7 +309,7 @@ describe.each(KINDS)('a control its own label covers, through the %s target', (k it('still refuses an Element Plus radio-button a disabled fieldset holds', async () => { await page.setContent(`
${ELEMENT_PLUS_CONTROLS}
`); for (const action of [{ kind: 'check' }, { kind: 'tap' }] as const) { - expect(await perform(await targetOf(kind, '#install'), action)).toMatchObject({ + expect(await perform(await targetOf(kind, '#install'), action, REFUSAL_TIMEOUT_MS)).toMatchObject({ code: 'NOT_ACTIONABLE', message: expect.stringContaining('not enabled'), }); @@ -319,7 +322,7 @@ describe.each(KINDS)('a control its own label covers, through the %s target', (k `); for (const action of [{ kind: 'check' }, { kind: 'tap' }] as const) { - expect(await perform(await targetOf(kind, '#c'), action)).toMatchObject({ + expect(await perform(await targetOf(kind, '#c'), action, REFUSAL_TIMEOUT_MS)).toMatchObject({ code: 'NOT_ACTIONABLE', message: `${action.kind} did not become actionable in time: the control and its labels are not visible`, }); @@ -330,7 +333,7 @@ describe.each(KINDS)('a control its own label covers, through the %s target', (k it('still refuses a disabled Element Plus radio-button', async () => { await page.setContent(ELEMENT_PLUS_PAGE.replace('id="install"', 'id="install" disabled')); for (const action of [{ kind: 'check' }, { kind: 'tap' }] as const) { - expect(await perform(await targetOf(kind, '#install'), action)).toMatchObject({ code: 'NOT_ACTIONABLE' }); + expect(await perform(await targetOf(kind, '#install'), action, REFUSAL_TIMEOUT_MS)).toMatchObject({ code: 'NOT_ACTIONABLE' }); expect(await page.isChecked('#install')).toBe(false); } }); From dd7d358056a871d956f924cc24b3428fcb1db1b9 Mon Sep 17 00:00:00 2001 From: Samanyu Das Date: Fri, 6 Nov 2026 22:26:43 +1030 Subject: [PATCH 07/18] test(web): resolve the element target through ElementList, as an observed ref does Since #1571 an observed ref's handle is made on first use from the walk's in-page array. Building the check-actions element target the same way runs every label stand-in case on the path an agent step takes. Co-Authored-By: Claude Opus 5.5 --- packages/web/tests/integration/check-actions.test.ts | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/packages/web/tests/integration/check-actions.test.ts b/packages/web/tests/integration/check-actions.test.ts index e8080d3563..1d172b59a7 100644 --- a/packages/web/tests/integration/check-actions.test.ts +++ b/packages/web/tests/integration/check-actions.test.ts @@ -13,6 +13,7 @@ import { chromium, type Browser, type Page } from 'playwright-core'; import { afterAll, beforeAll, beforeEach, describe, expect, it } from 'vitest'; import type { LocatorAction } from 'e2e/engine'; import { classifyActionError, dispatchLocatorAction } from '../../src/actions.ts'; +import { ElementList } from '../../src/element-list.ts'; import type { ActionTarget } from '../../src/support.ts'; let browser: Browser; @@ -46,13 +47,15 @@ beforeEach(async () => { const KINDS = ['locator', 'element'] as const; -/** The control as the engine would hold it: a locator, or an element handle pinned by an observation. */ +/** + * The control as the engine would hold it: a locator, or the element handle + * an observed ref resolves to, made on first use from the walk's in-page array. + */ async function targetOf(kind: (typeof KINDS)[number], selector: string): Promise { const locator = page.locator(selector); if (kind === 'locator') return { kind, locator }; - const element = await locator.elementHandle(); - if (element === null) throw new Error(`no element for ${selector}`); - return { kind, element }; + const walk = new ElementList(await locator.evaluateHandle((node) => [node])); + return { kind, element: await walk.at(0) }; } /** A refusal waits out the whole deadline, so the cases that expect one take a short one. */ From eb1d933aea22a7561499bdb57e33e1517833ed4b Mon Sep 17 00:00:00 2001 From: Samanyu Das Date: Fri, 6 Nov 2026 22:39:27 +1030 Subject: [PATCH 08/18] test(web): cross-check a checkbox or radio its label draws over no box Element Plus shrinks its native checkbox to a 0x0 box under the label it draws. Chrome's accessibility tree lists the control, and the tree leaves it out, so an agent sees the label text with no checkbox and no state (#1593). This page fails the cross-check with five `chrome missing` lines until the reader lists the labelled ones. Co-Authored-By: Claude Opus 5.5 --- packages/web/tests/crosscheck/fixtures.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/packages/web/tests/crosscheck/fixtures.ts b/packages/web/tests/crosscheck/fixtures.ts index a494489968..b9529dfeb9 100644 --- a/packages/web/tests/crosscheck/fixtures.ts +++ b/packages/web/tests/crosscheck/fixtures.ts @@ -128,6 +128,18 @@ export const FIXTURE_PAGES: readonly FixturePage[] = [ `, }, + { + name: 'controls drawn by their label', + html: ` + + + + + + + + `, + }, { name: 'disabled states', html: ` From 74cf1b0b5e53f257dba667a4f9c43ce156d487d8 Mon Sep 17 00:00:00 2001 From: Samanyu Das Date: Fri, 6 Nov 2026 22:41:20 +1030 Subject: [PATCH 09/18] fix(web): list a checkbox or radio its own label draws over no box The reader treats a box with no width or height as hidden, as Playwright's `toBeVisible` does, and leaves hidden elements out of the observation. Element Plus shrinks its native checkbox to 0x0 under the box its label draws, so the agent saw the label text with no checkbox and no checked state, and a tap that ticked it reported no change (#1593). The walk now lists such a control while a label of its own renders, and marks it not hidden, as it does a select's options. Chrome's accessibility tree keeps the input, so the cross-check agrees on the labelled ones. A shrunk control with no rendered label element still shows a person nothing and stays out, recorded in expected.txt. Co-Authored-By: Claude Opus 5.5 --- packages/web/src/in-page/read-semantics.ts | 19 ++++++++++++++++++- packages/web/tests/crosscheck/expected.txt | 2 ++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/packages/web/src/in-page/read-semantics.ts b/packages/web/src/in-page/read-semantics.ts index 13ad9515fa..e4353a27de 100644 --- a/packages/web/src/in-page/read-semantics.ts +++ b/packages/web/src/in-page/read-semantics.ts @@ -1104,6 +1104,20 @@ export const readSemanticsFunction = ( return !(rect.width > 0 && rect.height > 0); }; + /** + * True for a checkbox or radio hidden only by having no box, with a label of + * its own that renders. Element Plus shrinks its native input to 0x0 under + * the box its label draws, so a person sees the control as that label, and a + * click on the label sets it. Chrome's accessibility tree keeps such an + * input, so the walk lists it too: otherwise the model reads the label text + * with no checkbox and no checked state. + */ + const isDrawnByLabel = (el: Element, style: CSSStyleDeclaration | undefined): boolean => { + if (!(el instanceof HTMLInputElement) || (el.type !== 'checkbox' && el.type !== 'radio')) return false; + if (style?.visibility !== 'visible' || isInClosedDetails(el) || isSkippedContent(el)) return false; + return [...(el.labels ?? [])].some((label) => !isHidden(label)); + }; + /** * What takes the element and everything under it out of the tree walk: an * `aria-hidden` or inert subtree, which the accessibility tree drops though @@ -1574,14 +1588,17 @@ export const readSemanticsFunction = ( } let nextParent = parent; + const drawnByLabel = hidden && isDrawnByLabel(el, style); // An empty painted rectangle carries no semantics to be "interesting" by and // is still something a person sees and aims at; `roleOf` names it `box`. - if (!hidden && (isInteresting(el) || isVisibleEmptyBox(el))) { + if ((!hidden || drawnByLabel) && (isInteresting(el) || isVisibleEmptyBox(el))) { if (nodes.length >= maxNodes) { truncated = true; return; } nextParent = include(el, parent, style); + // Listed on purpose, so not "hidden", as a select's options are below. + if (drawnByLabel) nodes[nextParent]!.states.hidden = false; } // A closed select paints none of its options, so the hidden test would // drop every one of them — and a model shown `combobox "Category"` alone diff --git a/packages/web/tests/crosscheck/expected.txt b/packages/web/tests/crosscheck/expected.txt index 3b335501f3..d1c0640a0c 100644 --- a/packages/web/tests/crosscheck/expected.txt +++ b/packages/web/tests/crosscheck/expected.txt @@ -2,6 +2,8 @@ # page | oracle field | role "name" | ours | theirs | reason # Generated by E2E_CROSSCHECK_UPDATE=1; edit only the reasons. See tests/crosscheck/expectations.ts. benchmark: file-round-trip | chrome name | button "" | ours | theirs Choose File | An unlabeled file input shows the browser's localized button text, which the page cannot read; Playwright reports it too, the tree leaves the input unnamed rather than guess the locale +fixture: controls drawn by their label | chrome missing | checkbox "" | ours no node | theirs checkbox | A checkbox with no box whose only label is not rendered shows a person nothing to aim at; the tree lists one only while a label of its own draws it +fixture: controls drawn by their label | chrome missing | checkbox "Unlabelled" | ours no node | theirs checkbox | An aria-label draws nothing: a checkbox with no box and no label element shows a person nothing to aim at, so the tree leaves it out fixture: disabled states | chrome disabled | group "Shipping" | ours true | theirs false | `:disabled` matches a disabled fieldset itself; the tree keeps that so the model reads why the controls inside are disabled. Chrome and Playwright mark only the controls fixture: disabled states | chrome selected | option "Poland" | ours true | theirs false | Chrome drops the selected state of an option in a disabled select; Playwright agrees with the tree that it is the value fixture: generated content | chrome name | link "Sign out" | ours Sign out | theirs | Chrome names a link whose only content is an icon-font glyph by the glyph, which is nothing once dropped; the tree falls back to its title so the model reads the word a person hovering it sees From da8729d0c9400b7ae062f88042295fa618512288 Mon Sep 17 00:00:00 2001 From: Samanyu Das Date: Fri, 6 Nov 2026 22:42:45 +1030 Subject: [PATCH 10/18] docs(web): say the agent sees a checkbox its label draws over no box Co-Authored-By: Claude Opus 5.5 --- .changeset/list-label-drawn-checkbox.md | 5 +++++ docs/web.mdx | 5 +++++ 2 files changed, 10 insertions(+) create mode 100644 .changeset/list-label-drawn-checkbox.md diff --git a/.changeset/list-label-drawn-checkbox.md b/.changeset/list-label-drawn-checkbox.md new file mode 100644 index 0000000000..35d12d128c --- /dev/null +++ b/.changeset/list-label-drawn-checkbox.md @@ -0,0 +1,5 @@ +--- +"@e2e-dev/web": patch +--- + +The agent now sees a checkbox or radio that a component library shrinks to no size under its own label (as in Element Plus), with its checked state. Before, it saw only the label text, and a tap that ticked the box reported no change. diff --git a/docs/web.mdx b/docs/web.mdx index 7e4a8bb16b..2aeec6692f 100644 --- a/docs/web.mdx +++ b/docs/web.mdx @@ -255,6 +255,11 @@ link is also listed as a control. The agent reads the first 512 characters of each block of text. In a longer block, e2e also lists its links and emphasized text on their own. +Elements with no size are left out, except a checkbox or radio that a +component library shrinks to no size under its own label, as Element Plus +does. The agent sees that control with its checked state, and a tap on it +clicks the label. + ### Scoping a test to one size `platforms` and `requires` can't select a viewport, because every browser From 69f87eaf6155dd6759f27d028f47a521c3fc3a5b Mon Sep 17 00:00:00 2001 From: Samanyu Das Date: Fri, 6 Nov 2026 23:01:30 +1030 Subject: [PATCH 11/18] test(web): pin that the observation shows a label-drawn checkbox the locator calls hidden Agent code skips a node whose hidden state is true, so the listed control must read as shown, while the locator path keeps Playwright's visibility. Co-Authored-By: Claude Opus 5.5 --- .../tests/integration/read-node-checked.test.ts | 14 ++++++++++++++ packages/web/tests/integration/visibility.test.ts | 2 ++ 2 files changed, 16 insertions(+) diff --git a/packages/web/tests/integration/read-node-checked.test.ts b/packages/web/tests/integration/read-node-checked.test.ts index e131fb4c53..9e00cb5c5f 100644 --- a/packages/web/tests/integration/read-node-checked.test.ts +++ b/packages/web/tests/integration/read-node-checked.test.ts @@ -70,6 +70,20 @@ describe('checked and selected', () => { expect(await page.getByRole('option').allTextContents()).toEqual(['Visible', 'Disabled', 'No visibility', 'Restored']); }); + it('lists a checkbox or radio its own label draws over no box as shown, with its checked state', async () => { + await page.setContent(` + + + + + `); + const nodes = await captureByTestId(); + expect(nodes.get('agree')).toMatchObject({ role: 'checkbox', name: 'Agree', states: { checked: true } }); + expect(nodes.get('large')).toMatchObject({ role: 'radio', name: 'Large', states: { checked: false } }); + for (const id of ['agree', 'large']) expect(nodes.get(id)?.states?.hidden).not.toBe(true); + expect(nodes.has('hidden-label')).toBe(false); + }); + it('applies the option limit to offered choices after hidden options are excluded', async () => { await page.setContent(``); const nodes = await captureByTestId(); diff --git a/packages/web/tests/integration/visibility.test.ts b/packages/web/tests/integration/visibility.test.ts index 39edf27acf..bef716364b 100644 --- a/packages/web/tests/integration/visibility.test.ts +++ b/packages/web/tests/integration/visibility.test.ts @@ -59,6 +59,7 @@ const PAGE = `
+ + `); + const nodes = await captureByTestId(); + for (const id of ['invisible', 'text', 'skipped', 'contents']) expect(nodes.has(id), id).toBe(false); + }); + it('applies the option limit to offered choices after hidden options are excluded', async () => { await page.setContent(``); const nodes = await captureByTestId(); From a29cc91f9fea3a3dc816ebcc08686f44b3a64445 Mon Sep 17 00:00:00 2001 From: Samanyu Das Date: Sat, 7 Nov 2026 07:58:16 +1030 Subject: [PATCH 15/18] fix(web): leave out a label-drawn checkbox whose label holds a link A tap on a box-less checkbox clicks its label, and `pickStandIn` refuses when the label's centre lands on a link, so the click follows no link. The reader still listed such a checkbox ("Accept the Terms and Conditions" in Element Plus), and its tap failed `element is not visible`. The reader now counts only a label that holds no link or control besides its own, which is stricter than the tap, so it lists no checkbox the tap refuses. The action test now uses only box-less controls and checks each one has no box. The docs say when the agent sees only the label text. Co-Authored-By: Claude Opus 5.5 --- docs/web.mdx | 7 ++++--- packages/web/src/in-page/read-semantics.ts | 16 ++++++++++++---- packages/web/tests/crosscheck/expected.txt | 1 + packages/web/tests/crosscheck/fixtures.ts | 1 + .../web/tests/integration/check-actions.test.ts | 10 +++++++--- .../tests/integration/read-node-checked.test.ts | 5 +++-- 6 files changed, 28 insertions(+), 12 deletions(-) diff --git a/docs/web.mdx b/docs/web.mdx index ca641c2645..7c329c9bfe 100644 --- a/docs/web.mdx +++ b/docs/web.mdx @@ -257,9 +257,10 @@ emphasized text on their own. The agent also sees a checkbox or radio that a component library shrinks to no size under its own label, as Element Plus does, with its checked -state. A tap on it clicks the label. Locators still call that control -hidden, as Playwright does, so check it with `toBeChecked()`, not -`toBeVisible()`. +state. A tap on it clicks the label. When that label holds a link or +another control, the agent sees only the label text, since a click on the +label could land on the link. Locators still call that control hidden, as +Playwright does, so check it with `toBeChecked()`, not `toBeVisible()`. ### Scoping a test to one size diff --git a/packages/web/src/in-page/read-semantics.ts b/packages/web/src/in-page/read-semantics.ts index 7b4344ff19..ee7b3fd1ef 100644 --- a/packages/web/src/in-page/read-semantics.ts +++ b/packages/web/src/in-page/read-semantics.ts @@ -1106,14 +1106,22 @@ export const readSemanticsFunction = ( /** * True for a checkbox or radio hidden only by having no box, under a shown - * label of its own that has a box, as Element Plus draws one. A tap clicks - * that label (`pickStandIn` in `actions.ts`), so a `display: contents` - * label, which has no box to click, does not count. + * label of its own that draws it, as in Element Plus. Chrome's tree keeps + * such an input, and without it the model reads the label text with no + * checked state. A tap clicks the label in its place (`pickStandIn` in + * `actions.ts`), which needs a box (so not `display: contents`) and refuses + * a link or other control inside the label, so neither counts here. */ const isDrawnByLabel = (el: Element, style: CSSStyleDeclaration | undefined): boolean => { if (!(el instanceof HTMLInputElement) || (el.type !== 'checkbox' && el.type !== 'radio')) return false; if (style?.visibility !== 'visible' || isSkippedContent(el)) return false; - return associatedLabels(el).some((label) => styleOf(label)?.display !== 'contents' && !isHidden(label)); + const INTERACTIVE = 'a,button,input,select,textarea,summary,[contenteditable],[role="button"],[role="link"]'; + return associatedLabels(el).some( + (label) => + styleOf(label)?.display !== 'contents' && + !isHidden(label) && + !Array.from(label.querySelectorAll(INTERACTIVE)).some((inner) => inner !== el), + ); }; /** diff --git a/packages/web/tests/crosscheck/expected.txt b/packages/web/tests/crosscheck/expected.txt index cb4d15bcfa..26dd687d81 100644 --- a/packages/web/tests/crosscheck/expected.txt +++ b/packages/web/tests/crosscheck/expected.txt @@ -3,6 +3,7 @@ # Generated by E2E_CROSSCHECK_UPDATE=1; edit only the reasons. See tests/crosscheck/expectations.ts. benchmark: file-round-trip | chrome name | button "" | ours | theirs Choose File | An unlabeled file input shows the browser's localized button text, which the page cannot read; Playwright reports it too, the tree leaves the input unnamed rather than guess the locale fixture: controls drawn by their label | chrome missing | checkbox "" | ours no node | theirs checkbox | A checkbox with no box whose only label is not rendered shows a person nothing to aim at; the tree lists one only while a label of its own draws it +fixture: controls drawn by their label | chrome missing | checkbox "Accept the terms" | ours no node | theirs checkbox | A tap on a checkbox with no box clicks its label, which it refuses when the label holds a link, so the click follows no link; the tree leaves the checkbox out rather than list one a tap cannot reach fixture: controls drawn by their label | chrome missing | checkbox "Contents" | ours no node | theirs checkbox | A `display: contents` label has no box, so a tap cannot click it in place of a checkbox with no box; the tree leaves the checkbox out and the model taps the label text, which sets it fixture: controls drawn by their label | chrome missing | checkbox "Unlabelled" | ours no node | theirs checkbox | An aria-label draws nothing: a checkbox with no box and no label element shows a person nothing to aim at, so the tree leaves it out fixture: disabled states | chrome disabled | group "Shipping" | ours true | theirs false | `:disabled` matches a disabled fieldset itself; the tree keeps that so the model reads why the controls inside are disabled. Chrome and Playwright mark only the controls diff --git a/packages/web/tests/crosscheck/fixtures.ts b/packages/web/tests/crosscheck/fixtures.ts index b6f740f557..ded135e02d 100644 --- a/packages/web/tests/crosscheck/fixtures.ts +++ b/packages/web/tests/crosscheck/fixtures.ts @@ -140,6 +140,7 @@ export const FIXTURE_PAGES: readonly FixturePage[] = [ + `, }, { diff --git a/packages/web/tests/integration/check-actions.test.ts b/packages/web/tests/integration/check-actions.test.ts index fd611215dc..c52181b984 100644 --- a/packages/web/tests/integration/check-actions.test.ts +++ b/packages/web/tests/integration/check-actions.test.ts @@ -370,8 +370,11 @@ describe.each(KINDS)('a control its own label covers, through the %s target', (k describe('a checkbox or radio an observation lists over no box', () => { it('takes a tap on its listed node, so the walk lists none a tap cannot reach', async () => { - await page.setContent(`${ELEMENT_PLUS_CONTROLS} - `); + await page.setContent(` + + + + `); let nextId = 1; const published = new Published(); try { @@ -392,9 +395,10 @@ describe('a checkbox or radio an observation lists over no box', () => { }; walk(tree); const listed = nodes.filter((node) => node.role === 'checkbox' || node.role === 'radio'); - expect(listed.map((node) => node.name)).toEqual(['安装', '卸载', 'Agree', 'Large']); + expect(listed.map((node) => node.name)).toEqual(['Agree', 'Small']); for (const node of listed) { const element = await published.element(node.ref.id); + expect(await element.evaluate((input) => input.getBoundingClientRect().width), node.name ?? '').toBe(0); expect(await perform({ kind: 'element', element }, { kind: 'tap' }), node.name ?? '').toBeUndefined(); expect(await element.evaluate((input) => (input as HTMLInputElement).checked), node.name ?? '').toBe(true); } diff --git a/packages/web/tests/integration/read-node-checked.test.ts b/packages/web/tests/integration/read-node-checked.test.ts index 5f51df0413..36c52b2da5 100644 --- a/packages/web/tests/integration/read-node-checked.test.ts +++ b/packages/web/tests/integration/read-node-checked.test.ts @@ -84,7 +84,7 @@ describe('checked and selected', () => { expect(nodes.has('hidden-label')).toBe(false); }); - it('leaves out a box-less control no label of its own draws with a box a click can land on', async () => { + it('leaves out a box-less control no label of its own draws in a way a tap can click', async () => { await page.setContent(` @@ -92,6 +92,7 @@ describe('checked and selected', () => { + `); const nodes = await captureByTestId(); - for (const id of ['invisible', 'text', 'skipped', 'contents']) expect(nodes.has(id), id).toBe(false); + for (const id of ['invisible', 'text', 'skipped', 'contents', 'link']) expect(nodes.has(id), id).toBe(false); }); it('applies the option limit to offered choices after hidden options are excluded', async () => { From 0dab44467dc819d1772a6d258746f077b215e21f Mon Sep 17 00:00:00 2001 From: Samanyu Das Date: Sat, 7 Nov 2026 08:53:11 +1030 Subject: [PATCH 16/18] docs(web): say the agent still sees a link inside a label-drawn checkbox's label Co-Authored-By: Claude Opus 5.5 --- docs/web.mdx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/web.mdx b/docs/web.mdx index 7c329c9bfe..bba55ae701 100644 --- a/docs/web.mdx +++ b/docs/web.mdx @@ -258,8 +258,8 @@ emphasized text on their own. The agent also sees a checkbox or radio that a component library shrinks to no size under its own label, as Element Plus does, with its checked state. A tap on it clicks the label. When that label holds a link or -another control, the agent sees only the label text, since a click on the -label could land on the link. Locators still call that control hidden, as +another control, the agent sees the label's text and that control but not +the checkbox, since a click on the label could land on the link. Locators still call that control hidden, as Playwright does, so check it with `toBeChecked()`, not `toBeVisible()`. ### Scoping a test to one size From ec2c689fb5ff0d267d45b388f7f41b25ee5403f9 Mon Sep 17 00:00:00 2001 From: Samanyu Das Date: Sat, 7 Nov 2026 13:18:58 +1030 Subject: [PATCH 17/18] test(web): pin the clicked control and cover uncheck through a label A locator that matches another control after the state read must still click the control it read. Removing the pinned element from setChecked fails the new case. uncheck on an Element Plus checkbox clears it through its label, and on an Element Plus radio it is refused with no click. Turning the label stand-in off fails it. Co-Authored-By: Claude Opus 5.5 --- .../tests/integration/check-actions.test.ts | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/packages/web/tests/integration/check-actions.test.ts b/packages/web/tests/integration/check-actions.test.ts index 1d172b59a7..28b8bf6d7a 100644 --- a/packages/web/tests/integration/check-actions.test.ts +++ b/packages/web/tests/integration/check-actions.test.ts @@ -194,6 +194,34 @@ describe('a control gone before the click', () => { }); }); +describe('a locator that matches another control after the state read', () => { + it('clicks the control it read, not the one the locator matches now', async () => { + await page.setContent(` + + `); + const locator = page.locator('[data-pick]'); + const moved = new Proxy(locator, { + get(real, property) { + if (property === 'elementHandle') { + return async (options?: { timeout?: number }) => { + const element = await real.elementHandle(options); + await page.evaluate(() => { + document.getElementById('first')!.removeAttribute('data-pick'); + document.getElementById('second')!.setAttribute('data-pick', ''); + }); + return element; + }; + } + const value: unknown = Reflect.get(real, property); + return typeof value === 'function' ? value.bind(real) : value; + }, + }); + expect(await perform({ kind: 'locator', locator: moved }, { kind: 'check' })).toBeUndefined(); + expect(await page.isChecked('#first')).toBe(true); + expect(await page.isChecked('#second')).toBe(false); + }); +}); + const ELEMENT_PLUS_CSS = ` .el-radio-button{outline:none;display:inline-block;position:relative} .el-radio-button__original-radio{opacity:0;z-index:-1;outline:none;position:absolute} @@ -237,6 +265,19 @@ describe.each(KINDS)('a control its own label covers, through the %s target', (k expect(await page.isChecked(selector)).toBe(true); }); + it('unchecks an Element Plus checkbox, and refuses an Element Plus radio without clicking it', async () => { + await page.setContent(`${COUNT_CLICKS}${ELEMENT_PLUS_PAGE}`); + await page.evaluate(() => { + for (const id of ['agree', 'large']) (document.getElementById(id) as HTMLInputElement).checked = true; + }); + expect(await perform(await targetOf(kind, '#agree'), { kind: 'uncheck' })).toBeUndefined(); + expect(await page.isChecked('#agree')).toBe(false); + const before = await clicks(); + expect(await perform(await targetOf(kind, '#large'), { kind: 'uncheck' })).toMatchObject({ code: 'NOT_ACTIONABLE' }); + expect(await page.isChecked('#large')).toBe(true); + expect(await clicks()).toBe(before); + }); + it.each(ELEMENT_PLUS_CASES)('still refuses an Element Plus %s under a modal', async (_, selector) => { await page.setContent(`${ELEMENT_PLUS_PAGE}`); for (const action of [{ kind: 'check' }, { kind: 'tap' }] as const) { From 5ca70756fdde6a62887150c8b2c6f0fbea18bf5b Mon Sep 17 00:00:00 2001 From: Samanyu Das Date: Sat, 7 Nov 2026 13:19:00 +1030 Subject: [PATCH 18/18] fix(web): leave out a label-drawn checkbox whose label is itself a control A label with role="button", role="link", or contenteditable listed its box-less checkbox, but a tap on it fails NOT_ACTIONABLE, because pickStandIn's closest() check matches the label itself. The reader now skips such a label too, so the agent taps the label, as on main. The JSDoc, the cross-check reason, and docs/web.mdx now say the tap refuses only when the label's centre lands on a link, and that the reader's rule is stricter. Co-Authored-By: Claude Opus 5.5 --- docs/web.mdx | 6 +++--- packages/web/src/in-page/read-semantics.ts | 4 +++- packages/web/tests/crosscheck/expected.txt | 2 +- packages/web/tests/integration/read-node-checked.test.ts | 7 ++++++- 4 files changed, 13 insertions(+), 6 deletions(-) diff --git a/docs/web.mdx b/docs/web.mdx index bba55ae701..32db8ddc50 100644 --- a/docs/web.mdx +++ b/docs/web.mdx @@ -257,9 +257,9 @@ emphasized text on their own. The agent also sees a checkbox or radio that a component library shrinks to no size under its own label, as Element Plus does, with its checked -state. A tap on it clicks the label. When that label holds a link or -another control, the agent sees the label's text and that control but not -the checkbox, since a click on the label could land on the link. Locators still call that control hidden, as +state. A tap on it clicks the label. When that label is or holds a link +or another control, the agent sees the label's text and that control but +not the checkbox, since a click on the label could land on the link. Locators still call that control hidden, as Playwright does, so check it with `toBeChecked()`, not `toBeVisible()`. ### Scoping a test to one size diff --git a/packages/web/src/in-page/read-semantics.ts b/packages/web/src/in-page/read-semantics.ts index ee7b3fd1ef..2b9223a2e8 100644 --- a/packages/web/src/in-page/read-semantics.ts +++ b/packages/web/src/in-page/read-semantics.ts @@ -1110,7 +1110,8 @@ export const readSemanticsFunction = ( * such an input, and without it the model reads the label text with no * checked state. A tap clicks the label in its place (`pickStandIn` in * `actions.ts`), which needs a box (so not `display: contents`) and refuses - * a link or other control inside the label, so neither counts here. + * when the label's centre lands on a link or other control. This rule is + * stricter: a label that is one, or holds one anywhere, does not count. */ const isDrawnByLabel = (el: Element, style: CSSStyleDeclaration | undefined): boolean => { if (!(el instanceof HTMLInputElement) || (el.type !== 'checkbox' && el.type !== 'radio')) return false; @@ -1120,6 +1121,7 @@ export const readSemanticsFunction = ( (label) => styleOf(label)?.display !== 'contents' && !isHidden(label) && + !label.matches(INTERACTIVE) && !Array.from(label.querySelectorAll(INTERACTIVE)).some((inner) => inner !== el), ); }; diff --git a/packages/web/tests/crosscheck/expected.txt b/packages/web/tests/crosscheck/expected.txt index 26dd687d81..be79ca7f38 100644 --- a/packages/web/tests/crosscheck/expected.txt +++ b/packages/web/tests/crosscheck/expected.txt @@ -3,7 +3,7 @@ # Generated by E2E_CROSSCHECK_UPDATE=1; edit only the reasons. See tests/crosscheck/expectations.ts. benchmark: file-round-trip | chrome name | button "" | ours | theirs Choose File | An unlabeled file input shows the browser's localized button text, which the page cannot read; Playwright reports it too, the tree leaves the input unnamed rather than guess the locale fixture: controls drawn by their label | chrome missing | checkbox "" | ours no node | theirs checkbox | A checkbox with no box whose only label is not rendered shows a person nothing to aim at; the tree lists one only while a label of its own draws it -fixture: controls drawn by their label | chrome missing | checkbox "Accept the terms" | ours no node | theirs checkbox | A tap on a checkbox with no box clicks its label, which it refuses when the label holds a link, so the click follows no link; the tree leaves the checkbox out rather than list one a tap cannot reach +fixture: controls drawn by their label | chrome missing | checkbox "Accept the terms" | ours no node | theirs checkbox | A tap on a checkbox with no box clicks its label, which it refuses when the label's centre lands on a link, so the click follows no link; the tree leaves the checkbox out when its label holds a link anywhere, a stricter rule, rather than list one a tap may not reach fixture: controls drawn by their label | chrome missing | checkbox "Contents" | ours no node | theirs checkbox | A `display: contents` label has no box, so a tap cannot click it in place of a checkbox with no box; the tree leaves the checkbox out and the model taps the label text, which sets it fixture: controls drawn by their label | chrome missing | checkbox "Unlabelled" | ours no node | theirs checkbox | An aria-label draws nothing: a checkbox with no box and no label element shows a person nothing to aim at, so the tree leaves it out fixture: disabled states | chrome disabled | group "Shipping" | ours true | theirs false | `:disabled` matches a disabled fieldset itself; the tree keeps that so the model reads why the controls inside are disabled. Chrome and Playwright mark only the controls diff --git a/packages/web/tests/integration/read-node-checked.test.ts b/packages/web/tests/integration/read-node-checked.test.ts index 36c52b2da5..cc279b73cc 100644 --- a/packages/web/tests/integration/read-node-checked.test.ts +++ b/packages/web/tests/integration/read-node-checked.test.ts @@ -93,6 +93,9 @@ describe('checked and selected', () => { + + + `); const nodes = await captureByTestId(); - for (const id of ['invisible', 'text', 'skipped', 'contents', 'link']) expect(nodes.has(id), id).toBe(false); + for (const id of ['invisible', 'text', 'skipped', 'contents', 'link', 'button-label', 'link-label', 'editable-label']) { + expect(nodes.has(id), id).toBe(false); + } }); it('applies the option limit to offered choices after hidden options are excluded', async () => {