Playwright · Junior · Question 16 of 75

When is getByPlaceholder a reasonable choice?

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.

Further reading

Problem with a question

Playwright · Junior · question 16

Test yourself

Take the Playwright · Junior quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz