79363641

Date: 2025-01-17 05:07:57
Score: 0.5
Natty:
Report link

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

enter image description here

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;
}
Reasons:
  • Probably link only (1):
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Low reputation (0.5):
Posted by: Penzias