Description
Version
1.60.0
Steps to reproduce
import { expect, test } from '@playwright/test';
test.describe('locator.fill() silently does nothing inside [inert] container', () => {
test.beforeEach(async ({ page }) => {
await page.setContent(`
<div inert id="locker">
<input id="target">
</div>
<input id="outside">
`);
});
test('fill() resolves successfully but the input stays empty', async ({ page }) => {
const target = page.locator('#target');
// All fill() actionability checks pass although the element is inert:
// visible / enabled / editable do not consider the inert attribute
// (aria-disabled="true" on the container would make "enabled" fail).
await expect(target).toBeVisible();
await expect(target).toBeEnabled();
await expect(target).toBeEditable();
// This resolves WITHOUT any error...
await target.fill('hello');
// ...but the value is silently dropped: injected fill does
// input.focus() (silently fails inside inert subtree), then
// Input.insertText goes to the actual focused element (<body>),
// and dom.ts returns 'done' without verifying element.value.
await expect(target).toHaveValue('');
});
test('contrast: click() on the same element waits and times out', async ({ page }) => {
const target = page.locator('#target');
// click() is properly blocked: the browser hit-testing skips inert
// subtrees, so the hit-target check keeps failing.
await expect(target.click({ timeout: 3_000 })).rejects.toThrow(/timeout/i);
});
test('contrast: press() sends keystrokes to an unrelated focused element', async ({ page }) => {
const target = page.locator('#target');
const outside = page.locator('#outside');
await outside.focus();
// press() = actionability checks + focus() + key press.
// The focus() call silently fails (inert), so the keystroke
// lands in whatever was focused before — a field outside the locker.
await target.press('a');
await expect(target).toHaveValue('');
await expect(outside).toHaveValue('a');
});
test('contrast: the same input inside [aria-disabled] container is properly waited on', async ({ page }) => {
await page.setContent(`
<div aria-disabled="true" id="locker">
<input id="target">
</div>
`);
const target = page.locator('#target');
// aria-disabled IS honored: getAriaDisabled() walks up the ancestor
// hierarchy (roleUtils.ts), so the "enabled" actionability check fails
// and fill() keeps retrying instead of silently doing nothing.
await expect(target.fill('hello', { timeout: 3_000 })).rejects.toThrow(/timeout/i);
await expect(target).toHaveValue('');
// Emulate unlocking: remove the attribute...
await page.locator('#locker').evaluate(el => el.removeAttribute('aria-disabled'));
// ...and the same fill() now proceeds and applies the value.
// This end-to-end "wait until unlocked" behavior is exactly what
// [inert] containers are missing (see TODO in roleUtils.isFocusable).
await target.fill('hello');
await expect(target).toHaveValue('hello');
});
});
Expected behavior
fill()/press()/type() should keep retrying while the element is inside an inert subtree (consistent with click() and aria-disabled="true").
Actual behavior
locator.fill() on an element inside an inert container passes all actionability checks (visible/enabled/editable), resolves successfully, but the value is not applied — focus() silently fails on inert elements, Input.insertText goes to the currently focused element.
keyboard.insertText → return 'done', never verifies that the element actually received the value. Worse, locator.press() delivers keystrokes to an unrelated focused element (data corruption in a different field). locator.click() on the same element is properly blocked by the hit-target check, since browser hit-testing skips inert subtrees.
Additional context
No response
Environment
System:
OS: Windows 10 10.0.19044
CPU: (20) x64 12th Gen Intel(R) Core(TM) i7-12800H
Memory: 6.27 GB / 31.69 GB
Binaries:
Node: 24.19.0 - C:\Program Files\nodejs\node.EXE
npm: 11.17.0 - C:\Program Files\nodejs\npm.CMD
Languages:
Bash: 5.1.16 - C:\WINDOWS\system32\bash.EXE
npmPackages:
@playwright/test: 1.60.0 => 1.60.0
playwright-core: 1.60.0 => 1.60.0
playwright-msw: 3.0.1 => 3.0.1
Activity
msgoloborodov commentedon Sep 28, 2026
Related issue: #36938
github-actions commentedon Sep 29, 2026
Hi, I'm the Playwright bot and I took a first look at this.
Reproduced on tip-of-tree (
@playwright/[email protected]) in Chromium, Firefox and WebKit, all headless. All three engines behave the same way. When the input sits inside aninertcontainer:fill()succeeds, but the input stays empty.press()/pressSequentially()succeed, but the keys go to whatever element already had focus (#outsideends up witha/ab).click()keeps retrying and times out, as expected, because hit-testing skips inert subtrees.This comes from the actionability checks.
fill/presscheck visible/enabled/editable, and none of those look atinert. The injectedfocus()then fails without an error, and the text goes to whatever element has focus. There's an existing TODO for this inpackages/injected/src/roleUtils.ts(isFocusable: "inert" attribute makes the whole subtree not focusable).This looks like a real bug. #42125 is a related report that was closed as by design, but there focus moved away during
fill()because of page script. Here the target can't receive focus at all, and Playwright could detect that before typing. #36938 (inert elements not being hidden fromgetByRole) is related but separate.Condensed repro
What I ran
@playwright/[email protected], Linux, headless,<div inert><input id="target"></div><input id="outside">:fill('hello')""press('a')with#outsidefocused#outside=apressSequentially('ab')with#outsidefocused#outside=abclick()I didn't re-run on 1.60.0 because tip-of-tree already reproduces it, and I didn't test headed mode.
Triaged on Linux by the Playwright bot - agent run
hoangtaiki commentedon Oct 6, 2026
Dmitry Gozman (@dgozman) I see this is assigned to you. If you'd welcome a community PR for it, I'd be happy to send one.
I have a local fix with tests passing on Chromium, Firefox and WebKit.
fill(),clear(),press()andpressSequentially()wait while the target has an[inert]ancestor (crossing shadow roots), then act once it's removed. If it never is, they time out with "element is inert" in the call log, the same wayclick()already times out on inert elements.fill({ force: true })skips the check like other actionability checks.I've read the history in #36938 / #36947 / #37137 and the closed #42990. This change does not touch
roleUtilsor locator/aria matching, and unlike #42990 it does not change the "editable" state, sogetByRole()andtoBeEditable()behave as before. I'd also keeplocator.focus()unchanged, since a test may callfocus()on an inert element to assert that it can't be focused.Two open questions:
<dialog>be treated the same way? My fix only handles theinertattribute.Happy to adjust if you'd prefer a different approach.
chore: mark v0.1.23 (#494)