Playwright · Junior · Question 19 of 75
Which locator finds an image by its alt text?
- 1
page.getByTitle('Company logo') - 2
page.getByAltText('Company logo') - 3
page.getByImage('Company logo')
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.