Playwright · Senior · Question 39 of 77
What should a team policy on data-testid say?
- 1Use it when role and name aren't stable or unique
- 2Never use it, since it isn't visible to users
- 3Add it to every element instead of using roles
Show the answer
Correct answer: Use it when role and name aren't stable or unique
Explanation
Roles test accessibility for free. Test IDs fill gaps like repeated cards or canvas widgets, and should be stable, not generated.