You would need to use data-testid
not data-qa
. PrimeNG passes through data-testid
to the browser.
Playwright then uses it in getByTestId()
.
See Playwright docs - locate-by-test-id
Locate by test id
<button data-testid="directions">Itinéraire</button>
await page.getByTestId('directions').click();
Here is the PrimeNG sample with data-testid
added
data-qa
is similarly passed through in the app, but Playwright does not use it.
Here is the point where Playwright applies getByTestId()
// locator.ts, line 155
getByTestId(testId: string | RegExp): Locator {
return this.locator(getByTestIdSelector(testIdAttributeName(), testId));
}
// locator.ts, line 441
let _testIdAttributeName: string = 'data-testid'; // must be this attribute
export function testIdAttributeName(): string {
return _testIdAttributeName;
}