Skip to content
masterclass Buddy

Playwright · Function

locator

Playwright .NET locators find elements and support auto-waiting and retrying. Prefer role, label, text, placeholder, alt text, title, and test ID locators before CSS or XPath.

Last updated

Since
v1.14

Syntax

var locator = Page.GetByRole(AriaRole.Button, new() { Name = "Sign in" });

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

Subscribe
  • Page.GetByRole()
  • Page.GetByLabel()
  • Page.GetByPlaceholder()
  • Page.GetByText()
  • Page.GetByAltText()
  • Page.GetByTitle()
  • Page.GetByTestId()
  • Locator.Filter()

Source: Locators | Playwright .NET. Checked 2026-11-03.