Repository navigation
Description
Version
1.64.1 (same code on main)
Steps to reproduce
// repro.js, run with: node repro.js
const { chromium } = require('@playwright/test');
(async () => {
const browser = await chromium.launch();
const page = await browser.newPage();
await page.setContent(`
<div role="checkbox" aria-checked="True" tabindex="0" id="cb">Remember me</div>
<button aria-pressed="True">Bold</button>
<button aria-expanded="True">Menu</button>
<div role="Button" tabindex="0">Save</div>
<script>
cb.onclick = () => cb.setAttribute('aria-checked', String(cb.getAttribute('aria-checked').toLowerCase() !== 'true'));
</script>
`);
console.log('checked:', await page.getByRole('checkbox', { checked: true }).count());
console.log('pressed:', await page.getByRole('button', { pressed: true }).count());
console.log('expanded:', await page.getByRole('button', { expanded: true }).count());
console.log('button "Save":', await page.getByRole('button', { name: 'Save' }).count());
console.log(await page.locator('body').ariaSnapshot());
// What Chromium itself exposes
const cdp = await page.context().newCDPSession(page);
const { nodes } = await cdp.send('Accessibility.getFullAXTree');
for (const n of nodes.filter(n => ['checkbox', 'button'].includes(n.role?.value)))
console.log('chromium:', n.role.value, n.name.value, (n.properties || []).filter(p => ['checked', 'pressed', 'expanded'].includes(p.name)).map(p => `${p.name}=${p.value.value}`).join(' '));
await page.getByRole('checkbox').check().catch(e => console.log(e.message.split('\n')[0]));
console.log('aria-checked after check():', await page.locator('#cb').getAttribute('aria-checked'));
await browser.close();
})();Expected behavior
Same as what Chromium exposes: the checkbox is checked, the buttons are pressed / expanded, role="Button" is a button, and check() is a no-op because the box is already checked.
Actual behavior
checked: 0
pressed: 0
expanded: 0
button "Save": 0
- checkbox "Remember me"
- button "Bold"
- button "Menu"
- text: Save
chromium: checkbox Remember me checked=true
chromium: button Bold pressed=true
chromium: button Menu expanded=true
chromium: button Save
locator.check: Clicking the checkbox did not change its state
aria-checked after check(): false
check() is the nasty one: it reads the box as unchecked, clicks it (which actually unchecks it), then throws. toBeChecked(), getByRole({ checked | pressed | expanded }) and toMatchAriaSnapshot are all affected the same way.
Additional context
This shows up with server-rendered templates. Jinja and Django print Python booleans as True/False, so aria-checked="{{ item.done }}" ends up as aria-checked="True".
html-aria (§4.4) asks authors to use lowercase, but also notes that browsers treat role and token values case-insensitively, which matches the Chromium output above. Playwright already does that for aria-hidden, aria-selected and aria-disabled (getAriaBoolean() and the aria-disabled check in packages/injected/src/roleUtils.ts), but not for:
role(getExplicitAriaRole)aria-checked(getChecked)aria-pressed(getAriaPressed)aria-expanded(getAriaExpanded)aria-readonly(getReadonly)
These compare against 'true' / 'mixed' and the role list as-is. Lowercasing the value in those helpers should be enough. I'd like to send a PR for it, with tests in tests/page/selectors-role.spec.ts, if that works for you.
Environment
System:
OS: Linux 7.0 Ubuntu 26.04.1 LTS
CPU: (12) x64 AMD Ryzen 5 5500U with Radeon Graphics
Binaries:
Node: 24.14.1
npm: 11.11.0
npmPackages:
@playwright/test: 1.64.1
Activity
zerotohero3 commentedon Oct 28, 2026
Saw #43680 come in for this. The roleUtils change looks right to me. One thing: the new test is titled
SE-052b ..., which won't passlint-tests, because titles need anXX-123id plus an entry intests/registry.md. I'm fine with that one going in once that's fixed, or I can send mine, whatever's easier for you.github-actions commentedon Oct 28, 2026
github-actions commentedon Oct 28, 2026
Hi, I'm the Playwright bot and I reproduced this on Linux.
Reproduced in Chromium, Firefox and WebKit with Playwright
1.65.0-nextat1b9b602724484df3ebc41aba77824fdfaba861f6. The shared role and state readers compare these values case-sensitively, so they miss mixed-case roles and misread checked, pressed, expanded and readonly states. A fix is prepared with coverage for the reported filters, assertions, snapshots andcheck()leaving an already checked box unchanged.Draft fix: #43727
Triaged on Linux by the Playwright bot - agent run