Playwright · Junior · Question 19 of 75

Which locator finds an image by its alt text?

Show the answer

Correct answer: page.getByAltText('Company logo')

Explanation

getByAltText matches img and area elements by their alternative text, which also encourages meaningful alt attributes.

Further reading

Problem with a question

Playwright · Junior · question 19

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