Given markup like the following:
<dl>
<div>
<dt id="ticket-status">Status</dt>
<dd aria-labelledby="ticket-status">open</dd>
</div>
<div>
<dt id="ticket-team">Team</dt>
<dd aria-labelledby="ticket-team">My Team</dd>
</div>
</dl>
Using the following selector:
await expect(
page.getByRole('definition', { name: 'Status' })
).toBeVisible()
The <dd> containing "open" labeled by "Status" would be selected and the test passes.
The element is never found and an error is thrown
The odd part is that if I open the Testing Playground Chrome Extension, then evaluate:
screen.getByRole('defintion', { name: 'Status' })
That seems to work.
This thread is trying to answer question "Why does 'getByRole('definition', { name: 'Status' })' not work in the testing code but works in the Testing Playground Chrome Extension?"
Rayrun is a community for QA engineers. I am constantly looking for new ways to add value to people learning Playwright and other browser automation frameworks. If you have feedback, email [email protected].