Playwright · Method
page.getByTestId
page.getByTestId locates an element by its test ID and returns a Locator. It uses data-testid by default, but the test ID attribute can be configured.
Last updated
- Since
- v1.27
Syntax
page.getByTestId(testId)In-depth API docs are only for subscribers: parameters, examples, common mistakes and interview practice.
SubscribeRelated
locatorgetByRolegetByTextgetByLabelgetByPlaceholdergetByAltTextgetByTitleselectors.setTestIdAttribute