Playwright · Junior · Question 16 of 75
When is getByPlaceholder a reasonable choice?
- 1For inputs with a placeholder but no label
- 2For images that have alternative text
- 3For any element that shows text on the page
Show the answer
Correct answer: For inputs with a placeholder but no label
Explanation
Labels are better for accessibility, but if a field has only a placeholder, getByPlaceholder('Search') is still more readable and stable than CSS.