Skip to content
masterclass Buddy

Playwright · Method

page.getByAltText

getByAltText finds an element by its alternative text and returns a Locator. You can optionally require an exact, case-sensitive, whole-string match.

Last updated

Since
v1.27

Syntax

page.getByAltText(text)
page.getByAltText(text, options)

In-depth API docs are only for subscribers: parameters, examples, common mistakes and interview practice.

Subscribe
  • Locator
  • FrameLocator.getByAltText
  • Page.getByAltText
  • getByLabel
  • getByRole
  • getByText

Source: Locator | Playwright Java. Checked 2026-11-03.