Open luchsamapparat opened 1 month ago
The link probably points to a private repo, so I can't access. But I reproduce it with the following test:
import { expect, test } from '@playwright/test';
test('level', async ({ page }) => {
await page.setContent(`
<ul>
<li>
First Top-Level List Item
<div>
<ul>
<li>Second-Level List Item</li>
</ul>
</div>
</li>
<li>
Second Top-Level List Item
</li>
</ul>`);
expect(await page.getByRole('listitem', { level: 1 }).count()).toBe(2);
});
Oh, sorry, it‘s public now. But yes, it‘s identical to your reproduction
I looked over the ARIA specs and it seems like listitem
role does not expose levels anymore. Here are a few links:
listitem
role does not list aria-level
, that was removed by this change to the spec, see this issue.li
element mapping to ARIA does not list level either.aria-level
attribute explicitly lists comment
, heading
, row
and treeitem
. It allows user agents to calculate levels for DOM elements, but I can't find anything related to li
s.
Version
1.47.2
Steps to reproduce
npm install
npm run test
Expected behavior
Given this HTML...
...
getByRole('listitem', { level: 1 })
should return the two top-levellistitem
elements.Actual behavior
It returns 0 elements on all three browsers.
Additional context
Chrome DevTools provide correct values for the level property:
Environment