Table of Contents

Interface ILocator

Namespace
Microsoft.Playwright
Assembly
Microsoft.Playwright.dll

Locators are the central piece of Playwright's auto-waiting and retry-ability. In a nutshell, locators represent a way to find element(s) on the page at any moment. A locator can be created with the Locator(string, PageLocatorOptions?) method.

Learn more about locators.

public interface ILocator

Properties

ContentFrame

Returns a IFrameLocator object pointing to the same iframe as this locator.

Useful when you have a ILocator object obtained somewhere, and later on would like to interact with the content inside the frame.

For a reverse operation, use Owner.

**Usage**

var locator = Page.Locator("iframe[name=\"embedded\"]");
// ...
var frameLocator = locator.ContentFrame;
await frameLocator.GetByRole(AriaRole.Button).ClickAsync();
IFrameLocator ContentFrame { get; }

Property Value

IFrameLocator

First

Returns locator to the first matching element.

ILocator First { get; }

Property Value

ILocator

Last

Returns locator to the last matching element.

**Usage**

var banana = await page.GetByRole(AriaRole.Listitem).Last(1);
ILocator Last { get; }

Property Value

ILocator

Page

A page this locator belongs to.

IPage Page { get; }

Property Value

IPage

Methods

AllAsync()

When the locator points to a list of elements, this returns an array of locators, pointing to their respective elements.

**Usage**

foreach (var li in await page.GetByRole("listitem").AllAsync())
  await li.ClickAsync();
Task<IReadOnlyList<ILocator>> AllAsync()

Returns

Task<IReadOnlyList<ILocator>>

Remarks

AllAsync() does not wait for elements to match the locator, and instead immediately returns whatever is present in the page. When the list of elements changes dynamically, AllAsync() will produce unpredictable and flaky results. When the list of elements is stable, but loaded dynamically, wait for the full list to finish loading before calling AllAsync().

AllInnerTextsAsync()

Returns an array of node.innerText values for all matching nodes.

**Usage**

var texts = await page.GetByRole(AriaRole.Link).AllInnerTextsAsync();
Task<IReadOnlyList<string>> AllInnerTextsAsync()

Returns

Task<IReadOnlyList<string>>

Remarks

If you need to assert text on the page, prefer ToHaveTextAsync(string, LocatorAssertionsToHaveTextOptions?) with useInnerText option to avoid flakiness. See assertions guide for more details.

AllTextContentsAsync()

Returns an array of node.textContent values for all matching nodes.

**Usage**

var texts = await page.GetByRole(AriaRole.Link).AllTextContentsAsync();
Task<IReadOnlyList<string>> AllTextContentsAsync()

Returns

Task<IReadOnlyList<string>>

Remarks

If you need to assert text on the page, prefer ToHaveTextAsync(string, LocatorAssertionsToHaveTextOptions?) to avoid flakiness. See assertions guide for more details.

And(ILocator)

Creates a locator that matches both this locator and the argument locator.

**Usage**

The following example finds a button with a specific title.

var button = page.GetByRole(AriaRole.Button).And(page.GetByTitle("Subscribe"));
ILocator And(ILocator locator)

Parameters

locator ILocator

Additional locator to match.

Returns

ILocator

BlurAsync(LocatorBlurOptions?)

Calls blur on the element.

Task BlurAsync(LocatorBlurOptions? options = null)

Parameters

options LocatorBlurOptions

Call options

Returns

Task

BoundingBoxAsync(LocatorBoundingBoxOptions?)

This method returns the bounding box of the element matching the locator, or null if the element is not visible. The bounding box is calculated relative to the main frame viewport - which is usually the same as the browser window.

**Details**

Scrolling affects the returned bounding box, similarly to Element.getBoundingClientRect. That means x and/or y may be negative.

Elements from child frames return the bounding box relative to the main frame, unlike the Element.getBoundingClientRect.

Assuming the page is static, it is safe to use bounding box coordinates to perform input. For example, the following snippet should click the center of the element.

**Usage**

var box = await page.GetByRole(AriaRole.Button).BoundingBoxAsync();
await page.Mouse.ClickAsync(box.X + box.Width / 2, box.Y + box.Height / 2);
Task<LocatorBoundingBoxResult?> BoundingBoxAsync(LocatorBoundingBoxOptions? options = null)

Parameters

options LocatorBoundingBoxOptions

Call options

Returns

Task<LocatorBoundingBoxResult>

CheckAsync(LocatorCheckOptions?)

Ensure that checkbox or radio element is checked.

**Details**

Performs the following steps:

If the element is detached from the DOM at any moment during the action, this method throws.

When all steps combined have not finished during the specified timeout, this method throws a TimeoutException. Passing zero timeout disables this.

**Usage**

await page.GetByRole(AriaRole.Checkbox).CheckAsync();
Task CheckAsync(LocatorCheckOptions? options = null)

Parameters

options LocatorCheckOptions

Call options

Returns

Task

ClearAsync(LocatorClearOptions?)

Clear the input field.

**Details**

This method waits for actionability checks, focuses the element, clears it and triggers an input event after clearing.

If the target element is not an <input>, <textarea> or [contenteditable] element, this method throws an error. However, if the element is inside the <label> element that has an associated control, the control will be cleared instead.

**Usage**

await page.GetByRole(AriaRole.Textbox).ClearAsync();
Task ClearAsync(LocatorClearOptions? options = null)

Parameters

options LocatorClearOptions

Call options

Returns

Task

ClickAsync(LocatorClickOptions?)

Click an element.

**Details**

This method clicks the element by performing the following steps:

If the element is detached from the DOM at any moment during the action, this method throws.

When all steps combined have not finished during the specified timeout, this method throws a TimeoutException. Passing zero timeout disables this.

**Usage**

Click a button:

await page.GetByRole(AriaRole.Button).ClickAsync();

Shift-right-click at a specific position on a canvas:

await page.Locator("canvas").ClickAsync(new() {
  Button = MouseButton.Right,
  Modifiers = new[] { KeyboardModifier.Shift },
  Position = new Position { X = 0, Y = 0 }
});
Task ClickAsync(LocatorClickOptions? options = null)

Parameters

options LocatorClickOptions

Call options

Returns

Task

CountAsync()

Returns the number of elements matching the locator.

**Usage**

int count = await page.GetByRole(AriaRole.Listitem).CountAsync();
Task<int> CountAsync()

Returns

Task<int>

Remarks

If you need to assert the number of elements on the page, prefer ToHaveCountAsync(int, LocatorAssertionsToHaveCountOptions?) to avoid flakiness. See assertions guide for more details.

DblClickAsync(LocatorDblClickOptions?)

Double-click an element.

**Details**

This method double clicks the element by performing the following steps:

If the element is detached from the DOM at any moment during the action, this method throws.

When all steps combined have not finished during the specified timeout, this method throws a TimeoutException. Passing zero timeout disables this.

Task DblClickAsync(LocatorDblClickOptions? options = null)

Parameters

options LocatorDblClickOptions

Call options

Returns

Task

Remarks

element.dblclick() dispatches two click events and a single dblclick event.

DispatchEventAsync(string, object?, LocatorDispatchEventOptions?)

Programmatically dispatch an event on the matching element.

**Usage**

await locator.DispatchEventAsync("click");

**Details**

The snippet above dispatches the click event on the element. Regardless of the visibility state of the element, click is dispatched. This is equivalent to calling element.click().

Under the hood, it creates an instance of an event based on the given type, initializes it with eventInit properties and dispatches it on the element. Events are composed, cancelable and bubble by default.

Since eventInit is event-specific, please refer to the events documentation for the lists of initial properties:

You can also specify IJSHandle as the property value if you want live objects to be passed into the event:

var dataTransfer = await page.EvaluateHandleAsync("() => new DataTransfer()");
await locator.DispatchEventAsync("dragstart", new Dictionary<string, object>
{
    { "dataTransfer", dataTransfer }
});
Task DispatchEventAsync(string type, object? eventInit = null, LocatorDispatchEventOptions? options = null)

Parameters

type string

DOM event type: "click", "dragstart", etc.

eventInit object

Optional event-specific initialization properties.

options LocatorDispatchEventOptions

Call options

Returns

Task

DragToAsync(ILocator, LocatorDragToOptions?)

Drag the source element towards the target element and drop it.

**Details**

This method drags the locator to another target locator or target position. It will first move to the source element, perform a mousedown, then move to the target element or position and perform a mouseup.

**Usage**

var source = Page.Locator("#source");
var target = Page.Locator("#target");

await source.DragToAsync(target); // or specify exact positions relative to the top-left corners of the elements: await source.DragToAsync(target, new() { SourcePosition = new() { X = 34, Y = 7 }, TargetPosition = new() { X = 10, Y = 20 }, });

Task DragToAsync(ILocator target, LocatorDragToOptions? options = null)

Parameters

target ILocator

Locator of the element to drag to.

options LocatorDragToOptions

Call options

Returns

Task

ElementHandleAsync(LocatorElementHandleOptions?)

Always prefer using ILocators and web assertions over IElementHandles because latter are inherently racy.

Resolves given locator to the first matching DOM element. If there are no matching elements, waits for one. If multiple elements match the locator, throws.

Task<IElementHandle> ElementHandleAsync(LocatorElementHandleOptions? options = null)

Parameters

options LocatorElementHandleOptions

Call options

Returns

Task<IElementHandle>

ElementHandlesAsync()

Always prefer using ILocators and web assertions over IElementHandles because latter are inherently racy.

Resolves given locator to all matching DOM elements. If there are no matching elements, returns an empty list.

Task<IReadOnlyList<IElementHandle>> ElementHandlesAsync()

Returns

Task<IReadOnlyList<IElementHandle>>

EvaluateAllAsync<T>(string, object?)

Execute JavaScript code in the page, taking all matching elements as an argument.

**Details**

Returns the return value of expression, called with an array of all matching elements as a first argument, and arg as a second argument.

If expression returns a Task, this method will wait for the promise to resolve and return its value.

If expression throws or rejects, this method throws.

**Usage**

var locator = page.Locator("div");
var moreThanTen = await locator.EvaluateAllAsync<bool>("(divs, min) => divs.length > min", 10);
Task<T> EvaluateAllAsync<T>(string expression, object? arg = null)

Parameters

expression string

JavaScript expression to be evaluated in the browser context. If the expression evaluates to a function, the function is automatically invoked.

arg object

Optional argument to pass to expression.

Returns

Task<T>

Type Parameters

T

EvaluateAsync(string, object, LocatorEvaluateOptions)

Task<JsonElement?> EvaluateAsync(string expression, object arg = null, LocatorEvaluateOptions options = null)

Parameters

expression string
arg object
options LocatorEvaluateOptions

Returns

Task<JsonElement?>

EvaluateAsync<T>(string, object?, LocatorEvaluateOptions?)

Execute JavaScript code in the page, taking the matching element as an argument.

**Details**

Returns the return value of expression, called with the matching element as a first argument, and arg as a second argument.

If expression returns a Task, this method will wait for the promise to resolve and return its value.

If expression throws or rejects, this method throws.

**Usage**

var tweets = page.Locator(".tweet .retweets");
Assert.AreEqual("10 retweets", await tweets.EvaluateAsync("node => node.innerText"));
Task<T> EvaluateAsync<T>(string expression, object? arg = null, LocatorEvaluateOptions? options = null)

Parameters

expression string

JavaScript expression to be evaluated in the browser context. If the expression evaluates to a function, the function is automatically invoked.

arg object

Optional argument to pass to expression.

options LocatorEvaluateOptions

Call options

Returns

Task<T>

Type Parameters

T

EvaluateHandleAsync(string, object?, LocatorEvaluateHandleOptions?)

Execute JavaScript code in the page, taking the matching element as an argument, and return a IJSHandle with the result.

**Details**

Returns the return value of expression as aIJSHandle, called with the matching element as a first argument, and arg as a second argument.

The only difference between EvaluateAsync(string, object, LocatorEvaluateOptions) and EvaluateHandleAsync(string, object?, LocatorEvaluateHandleOptions?) is that EvaluateHandleAsync(string, object?, LocatorEvaluateHandleOptions?) returns IJSHandle.

If expression returns a Task, this method will wait for the promise to resolve and return its value.

If expression throws or rejects, this method throws.

See EvaluateHandleAsync(string, object?) for more details.

Task<IJSHandle> EvaluateHandleAsync(string expression, object? arg = null, LocatorEvaluateHandleOptions? options = null)

Parameters

expression string

JavaScript expression to be evaluated in the browser context. If the expression evaluates to a function, the function is automatically invoked.

arg object

Optional argument to pass to expression.

options LocatorEvaluateHandleOptions

Call options

Returns

Task<IJSHandle>

FillAsync(string, LocatorFillOptions?)

Set a value to the input field.

**Usage**

await page.GetByRole(AriaRole.Textbox).FillAsync("example value");

**Details**

This method waits for actionability checks, focuses the element, fills it and triggers an input event after filling. Note that you can pass an empty string to clear the input field.

If the target element is not an <input>, <textarea> or [contenteditable] element, this method throws an error. However, if the element is inside the <label> element that has an associated control, the control will be filled instead.

To send fine-grained keyboard events, use PressSequentiallyAsync(string, LocatorPressSequentiallyOptions?).

Task FillAsync(string value, LocatorFillOptions? options = null)

Parameters

value string

Value to set for the <input>, <textarea> or [contenteditable] element.

options LocatorFillOptions

Call options

Returns

Task

Filter(LocatorFilterOptions?)

This method narrows existing locator according to the options, for example filters by text. It can be chained to filter multiple times.

**Usage**

var rowLocator = page.Locator("tr");
// ...
await rowLocator
    .Filter(new() { HasText = "text in column 1" })
    .Filter(new() {
        Has = page.GetByRole(AriaRole.Button, new() { Name = "column 2 button" } )
    })
    .ScreenshotAsync();
ILocator Filter(LocatorFilterOptions? options = null)

Parameters

options LocatorFilterOptions

Call options

Returns

ILocator

FocusAsync(LocatorFocusOptions?)

Calls focus on the matching element.

Task FocusAsync(LocatorFocusOptions? options = null)

Parameters

options LocatorFocusOptions

Call options

Returns

Task

FrameLocator(string)

When working with iframes, you can create a frame locator that will enter the iframe and allow locating elements in that iframe:

**Usage**

var locator = page.FrameLocator("iframe").GetByText("Submit");
await locator.ClickAsync();
IFrameLocator FrameLocator(string selector)

Parameters

selector string

A selector to use when resolving DOM element.

Returns

IFrameLocator

GetAttributeAsync(string, LocatorGetAttributeOptions?)

Returns the matching element's attribute value.

Task<string?> GetAttributeAsync(string name, LocatorGetAttributeOptions? options = null)

Parameters

name string

Attribute name to get the value for.

options LocatorGetAttributeOptions

Call options

Returns

Task<string>

Remarks

If you need to assert an element's attribute, prefer ToHaveAttributeAsync(string, string, LocatorAssertionsToHaveAttributeOptions?) to avoid flakiness. See assertions guide for more details.

GetByAltText(string, LocatorGetByAltTextOptions?)

Allows locating elements by their alt text.

**Usage**

For example, this method will find the image by alt text "Playwright logo":

await page.GetByAltText("Playwright logo").ClickAsync();
ILocator GetByAltText(string text, LocatorGetByAltTextOptions? options = null)

Parameters

text string

Text to locate the element for.

options LocatorGetByAltTextOptions

Call options

Returns

ILocator

GetByAltText(Regex, LocatorGetByAltTextOptions?)

Allows locating elements by their alt text.

**Usage**

For example, this method will find the image by alt text "Playwright logo":

await page.GetByAltText("Playwright logo").ClickAsync();
ILocator GetByAltText(Regex text, LocatorGetByAltTextOptions? options = null)

Parameters

text Regex

Text to locate the element for.

options LocatorGetByAltTextOptions

Call options

Returns

ILocator

GetByLabel(string, LocatorGetByLabelOptions?)

Allows locating input elements by the text of the associated <label> or aria-labelledby element, or by the aria-label attribute.

**Usage**

For example, this method will find inputs by label "Username" and "Password" in the following DOM:

await page.GetByLabel("Username").FillAsync("john");
await page.GetByLabel("Password").FillAsync("secret");
ILocator GetByLabel(string text, LocatorGetByLabelOptions? options = null)

Parameters

text string

Text to locate the element for.

options LocatorGetByLabelOptions

Call options

Returns

ILocator

GetByLabel(Regex, LocatorGetByLabelOptions?)

Allows locating input elements by the text of the associated <label> or aria-labelledby element, or by the aria-label attribute.

**Usage**

For example, this method will find inputs by label "Username" and "Password" in the following DOM:

await page.GetByLabel("Username").FillAsync("john");
await page.GetByLabel("Password").FillAsync("secret");
ILocator GetByLabel(Regex text, LocatorGetByLabelOptions? options = null)

Parameters

text Regex

Text to locate the element for.

options LocatorGetByLabelOptions

Call options

Returns

ILocator

GetByPlaceholder(string, LocatorGetByPlaceholderOptions?)

Allows locating input elements by the placeholder text.

**Usage**

For example, consider the following DOM structure.

You can fill the input after locating it by the placeholder text:

await page
    .GetByPlaceholder("name@example.com")
    .FillAsync("playwright@microsoft.com");
ILocator GetByPlaceholder(string text, LocatorGetByPlaceholderOptions? options = null)

Parameters

text string

Text to locate the element for.

options LocatorGetByPlaceholderOptions

Call options

Returns

ILocator

GetByPlaceholder(Regex, LocatorGetByPlaceholderOptions?)

Allows locating input elements by the placeholder text.

**Usage**

For example, consider the following DOM structure.

You can fill the input after locating it by the placeholder text:

await page
    .GetByPlaceholder("name@example.com")
    .FillAsync("playwright@microsoft.com");
ILocator GetByPlaceholder(Regex text, LocatorGetByPlaceholderOptions? options = null)

Parameters

text Regex

Text to locate the element for.

options LocatorGetByPlaceholderOptions

Call options

Returns

ILocator

GetByRole(AriaRole, LocatorGetByRoleOptions?)

Allows locating elements by their ARIA role, ARIA attributes and accessible name.

**Usage**

Consider the following DOM structure.

You can locate each element by it's implicit role:

await Expect(Page
    .GetByRole(AriaRole.Heading, new() { Name = "Sign up" }))
    .ToBeVisibleAsync();

await page .GetByRole(AriaRole.Checkbox, new() { Name = "Subscribe" }) .CheckAsync();

await page .GetByRole(AriaRole.Button, new() { NameRegex = new Regex("submit", RegexOptions.IgnoreCase) }) .ClickAsync();

**Details**

Role selector **does not replace** accessibility audits and conformance tests, but rather gives early feedback about the ARIA guidelines.

Many html elements have an implicitly defined role that is recognized by the role selector. You can find all the supported roles here. ARIA guidelines **do not recommend** duplicating implicit roles and attributes by setting role and/or aria-* attributes to default values.

ILocator GetByRole(AriaRole role, LocatorGetByRoleOptions? options = null)

Parameters

role AriaRole

Required aria role.

options LocatorGetByRoleOptions

Call options

Returns

ILocator

GetByTestId(string)

Locate element by the test id.

**Usage**

Consider the following DOM structure.

You can locate the element by it's test id:

await page.GetByTestId("directions").ClickAsync();

**Details**

By default, the data-testid attribute is used as a test id. Use SetTestIdAttribute(string) to configure a different test id attribute if necessary.

ILocator GetByTestId(string testId)

Parameters

testId string

Id to locate the element by.

Returns

ILocator

GetByTestId(Regex)

Locate element by the test id.

**Usage**

Consider the following DOM structure.

You can locate the element by it's test id:

await page.GetByTestId("directions").ClickAsync();

**Details**

By default, the data-testid attribute is used as a test id. Use SetTestIdAttribute(string) to configure a different test id attribute if necessary.

ILocator GetByTestId(Regex testId)

Parameters

testId Regex

Id to locate the element by.

Returns

ILocator

GetByText(string, LocatorGetByTextOptions?)

Allows locating elements that contain given text.

See also Filter(LocatorFilterOptions?) that allows to match by another criteria, like an accessible role, and then filter by the text content.

**Usage**

Consider the following DOM structure:

You can locate by text substring, exact string, or a regular expression:

// Matches <span>
page.GetByText("world");

// Matches first <div> page.GetByText("Hello world");

// Matches second <div> page.GetByText("Hello", new() { Exact = true });

// Matches both <div>s page.GetByText(new Regex("Hello"));

// Matches second <div> page.GetByText(new Regex("^hello$", RegexOptions.IgnoreCase));

**Details**

Matching by text always normalizes whitespace, even with exact match. For example, it turns multiple spaces into one, turns line breaks into spaces and ignores leading and trailing whitespace.

Input elements of the type button and submit are matched by their value instead of the text content. For example, locating by text "Log in" matches <input type=button value="Log in">.

ILocator GetByText(string text, LocatorGetByTextOptions? options = null)

Parameters

text string

Text to locate the element for.

options LocatorGetByTextOptions

Call options

Returns

ILocator

GetByText(Regex, LocatorGetByTextOptions?)

Allows locating elements that contain given text.

See also Filter(LocatorFilterOptions?) that allows to match by another criteria, like an accessible role, and then filter by the text content.

**Usage**

Consider the following DOM structure:

You can locate by text substring, exact string, or a regular expression:

// Matches <span>
page.GetByText("world");

// Matches first <div> page.GetByText("Hello world");

// Matches second <div> page.GetByText("Hello", new() { Exact = true });

// Matches both <div>s page.GetByText(new Regex("Hello"));

// Matches second <div> page.GetByText(new Regex("^hello$", RegexOptions.IgnoreCase));

**Details**

Matching by text always normalizes whitespace, even with exact match. For example, it turns multiple spaces into one, turns line breaks into spaces and ignores leading and trailing whitespace.

Input elements of the type button and submit are matched by their value instead of the text content. For example, locating by text "Log in" matches <input type=button value="Log in">.

ILocator GetByText(Regex text, LocatorGetByTextOptions? options = null)

Parameters

text Regex

Text to locate the element for.

options LocatorGetByTextOptions

Call options

Returns

ILocator

GetByTitle(string, LocatorGetByTitleOptions?)

Allows locating elements by their title attribute.

**Usage**

Consider the following DOM structure.

You can check the issues count after locating it by the title text:

await Expect(Page.GetByTitle("Issues count")).toHaveText("25 issues");
ILocator GetByTitle(string text, LocatorGetByTitleOptions? options = null)

Parameters

text string

Text to locate the element for.

options LocatorGetByTitleOptions

Call options

Returns

ILocator

GetByTitle(Regex, LocatorGetByTitleOptions?)

Allows locating elements by their title attribute.

**Usage**

Consider the following DOM structure.

You can check the issues count after locating it by the title text:

await Expect(Page.GetByTitle("Issues count")).toHaveText("25 issues");
ILocator GetByTitle(Regex text, LocatorGetByTitleOptions? options = null)

Parameters

text Regex

Text to locate the element for.

options LocatorGetByTitleOptions

Call options

Returns

ILocator

HighlightAsync()

Highlight the corresponding element(s) on the screen. Useful for debugging, don't commit the code that uses HighlightAsync().

Task HighlightAsync()

Returns

Task

HoverAsync(LocatorHoverOptions?)

Hover over the matching element.

**Usage**

await page.GetByRole(AriaRole.Link).HoverAsync();

**Details**

This method hovers over the element by performing the following steps:

If the element is detached from the DOM at any moment during the action, this method throws.

When all steps combined have not finished during the specified timeout, this method throws a TimeoutException. Passing zero timeout disables this.

Task HoverAsync(LocatorHoverOptions? options = null)

Parameters

options LocatorHoverOptions

Call options

Returns

Task

InnerHTMLAsync(LocatorInnerHTMLOptions?)

Returns the element.innerHTML.

Task<string> InnerHTMLAsync(LocatorInnerHTMLOptions? options = null)

Parameters

options LocatorInnerHTMLOptions

Call options

Returns

Task<string>

InnerTextAsync(LocatorInnerTextOptions?)

Returns the element.innerText.

Task<string> InnerTextAsync(LocatorInnerTextOptions? options = null)

Parameters

options LocatorInnerTextOptions

Call options

Returns

Task<string>

Remarks

If you need to assert text on the page, prefer ToHaveTextAsync(string, LocatorAssertionsToHaveTextOptions?) with useInnerText option to avoid flakiness. See assertions guide for more details.

InputValueAsync(LocatorInputValueOptions?)

Returns the value for the matching <input> or <textarea> or <select> element.

**Usage**

String value = await page.GetByRole(AriaRole.Textbox).InputValueAsync();

**Details**

Throws elements that are not an input, textarea or a select. However, if the element is inside the <label> element that has an associated control, returns the value of the control.

Task<string> InputValueAsync(LocatorInputValueOptions? options = null)

Parameters

options LocatorInputValueOptions

Call options

Returns

Task<string>

Remarks

If you need to assert input value, prefer ToHaveValueAsync(string, LocatorAssertionsToHaveValueOptions?) to avoid flakiness. See assertions guide for more details.

IsCheckedAsync(LocatorIsCheckedOptions?)

Returns whether the element is checked. Throws if the element is not a checkbox or radio input.

**Usage**

var isChecked = await page.GetByRole(AriaRole.Checkbox).IsCheckedAsync();
Task<bool> IsCheckedAsync(LocatorIsCheckedOptions? options = null)

Parameters

options LocatorIsCheckedOptions

Call options

Returns

Task<bool>

Remarks

If you need to assert that checkbox is checked, prefer ToBeCheckedAsync(LocatorAssertionsToBeCheckedOptions?) to avoid flakiness. See assertions guide for more details.

IsDisabledAsync(LocatorIsDisabledOptions?)

Returns whether the element is disabled, the opposite of enabled.

**Usage**

Boolean disabled = await page.GetByRole(AriaRole.Button).IsDisabledAsync();
Task<bool> IsDisabledAsync(LocatorIsDisabledOptions? options = null)

Parameters

options LocatorIsDisabledOptions

Call options

Returns

Task<bool>

Remarks

If you need to assert that an element is disabled, prefer ToBeDisabledAsync(LocatorAssertionsToBeDisabledOptions?) to avoid flakiness. See assertions guide for more details.

IsEditableAsync(LocatorIsEditableOptions?)

Returns whether the element is editable.

**Usage**

Boolean editable = await page.GetByRole(AriaRole.Textbox).IsEditableAsync();
Task<bool> IsEditableAsync(LocatorIsEditableOptions? options = null)

Parameters

options LocatorIsEditableOptions

Call options

Returns

Task<bool>

Remarks

If you need to assert that an element is editable, prefer ToBeEditableAsync(LocatorAssertionsToBeEditableOptions?) to avoid flakiness. See assertions guide for more details.

IsEnabledAsync(LocatorIsEnabledOptions?)

Returns whether the element is enabled.

**Usage**

Boolean enabled = await page.GetByRole(AriaRole.Button).IsEnabledAsync();
Task<bool> IsEnabledAsync(LocatorIsEnabledOptions? options = null)

Parameters

options LocatorIsEnabledOptions

Call options

Returns

Task<bool>

Remarks

If you need to assert that an element is enabled, prefer ToBeEnabledAsync(LocatorAssertionsToBeEnabledOptions?) to avoid flakiness. See assertions guide for more details.

IsHiddenAsync(LocatorIsHiddenOptions?)

Returns whether the element is hidden, the opposite of visible.

**Usage**

Boolean hidden = await page.GetByRole(AriaRole.Button).IsHiddenAsync();
Task<bool> IsHiddenAsync(LocatorIsHiddenOptions? options = null)

Parameters

options LocatorIsHiddenOptions

Call options

Returns

Task<bool>

Remarks

If you need to assert that element is hidden, prefer ToBeHiddenAsync(LocatorAssertionsToBeHiddenOptions?) to avoid flakiness. See assertions guide for more details.

IsVisibleAsync(LocatorIsVisibleOptions?)

Returns whether the element is visible.

**Usage**

Boolean visible = await page.GetByRole(AriaRole.Button).IsVisibleAsync();
Task<bool> IsVisibleAsync(LocatorIsVisibleOptions? options = null)

Parameters

options LocatorIsVisibleOptions

Call options

Returns

Task<bool>

Remarks

If you need to assert that element is visible, prefer ToBeVisibleAsync(LocatorAssertionsToBeVisibleOptions?) to avoid flakiness. See assertions guide for more details.

Locator(ILocator, LocatorLocatorOptions?)

The method finds an element matching the specified selector in the locator's subtree. It also accepts filter options, similar to Filter(LocatorFilterOptions?) method.

Learn more about locators.

ILocator Locator(ILocator selectorOrLocator, LocatorLocatorOptions? options = null)

Parameters

selectorOrLocator ILocator

A selector or locator to use when resolving DOM element.

options LocatorLocatorOptions

Call options

Returns

ILocator

Locator(string, LocatorLocatorOptions?)

The method finds an element matching the specified selector in the locator's subtree. It also accepts filter options, similar to Filter(LocatorFilterOptions?) method.

Learn more about locators.

ILocator Locator(string selectorOrLocator, LocatorLocatorOptions? options = null)

Parameters

selectorOrLocator string

A selector or locator to use when resolving DOM element.

options LocatorLocatorOptions

Call options

Returns

ILocator

Nth(int)

Returns locator to the n-th matching element. It's zero based, nth(0) selects the first element.

**Usage**

var banana = await page.GetByRole(AriaRole.Listitem).Nth(2);
ILocator Nth(int index)

Parameters

index int

Returns

ILocator

Or(ILocator)

Creates a locator that matches either of the two locators.

**Usage**

Consider a scenario where you'd like to click on a "New email" button, but sometimes a security settings dialog shows up instead. In this case, you can wait for either a "New email" button, or a dialog and act accordingly.

var newEmail = page.GetByRole(AriaRole.Button, new() { Name = "New" });
var dialog = page.GetByText("Confirm security settings");
await Expect(newEmail.Or(dialog)).ToBeVisibleAsync();
if (await dialog.IsVisibleAsync())
  await page.GetByRole(AriaRole.Button, new() { Name = "Dismiss" }).ClickAsync();
await newEmail.ClickAsync();
ILocator Or(ILocator locator)

Parameters

locator ILocator

Alternative locator to match.

Returns

ILocator

PressAsync(string, LocatorPressOptions?)

Focuses the matching element and presses a combination of the keys.

**Usage**

await page.GetByRole(AriaRole.Textbox).PressAsync("Backspace");

**Details**

Focuses the element, and then uses DownAsync(string) and UpAsync(string).

key can specify the intended keyboardEvent.key value or a single character to generate the text for. A superset of the key values can be found here. Examples of the keys are:

F1 - F12, Digit0- Digit9, KeyA- KeyZ, Backquote, Minus, Equal, Backslash, Backspace, Tab, Delete, Escape, ArrowDown, End, Enter, Home, Insert, PageDown, PageUp, ArrowRight, ArrowUp, etc.

Following modification shortcuts are also supported: Shift, Control, Alt, Meta, ShiftLeft, ControlOrMeta. ControlOrMeta resolves to Control on Windows and Linux and to Meta on macOS.

Holding down Shift will type the text that corresponds to the key in the upper case.

If key is a single character, it is case-sensitive, so the values a and A will generate different respective texts.

Shortcuts such as key: "Control+o", key: "Control++ or key: "Control+Shift+T" are supported as well. When specified with the modifier, modifier is pressed and being held while the subsequent key is being pressed.

Task PressAsync(string key, LocatorPressOptions? options = null)

Parameters

key string

Name of the key to press or a character to generate, such as ArrowLeft or a.

options LocatorPressOptions

Call options

Returns

Task

PressSequentiallyAsync(string, LocatorPressSequentiallyOptions?)

Focuses the element, and then sends a keydown, keypress/input, and keyup event for each character in the text.

To press a special key, like Control or ArrowDown, use PressAsync(string, LocatorPressOptions?).

**Usage**

await locator.PressSequentiallyAsync("Hello"); // Types instantly
await locator.PressSequentiallyAsync("World", new() { Delay = 100 }); // Types slower, like a user

An example of typing into a text field and then submitting the form:

var locator = page.GetByLabel("Password");
await locator.PressSequentiallyAsync("my password");
await locator.PressAsync("Enter");
Task PressSequentiallyAsync(string text, LocatorPressSequentiallyOptions? options = null)

Parameters

text string

String of characters to sequentially press into a focused element.

options LocatorPressSequentiallyOptions

Call options

Returns

Task

Remarks

In most cases, you should use FillAsync(string, LocatorFillOptions?) instead. You only need to press keys one by one if there is special keyboard handling on the page.

ScreenshotAsync(LocatorScreenshotOptions?)

Take a screenshot of the element matching the locator.

**Usage**

await page.GetByRole(AriaRole.Link).ScreenshotAsync();

Disable animations and save screenshot to a file:

await page.GetByRole(AriaRole.Link).ScreenshotAsync(new() {
  Animations = ScreenshotAnimations.Disabled,
  Path = "link.png"
});

**Details**

This method captures a screenshot of the page, clipped to the size and position of a particular element matching the locator. If the element is covered by other elements, it will not be actually visible on the screenshot. If the element is a scrollable container, only the currently scrolled content will be visible on the screenshot.

This method waits for the actionability checks, then scrolls element into view before taking a screenshot. If the element is detached from DOM, the method throws an error.

Returns the buffer with the captured screenshot.

Task<byte[]> ScreenshotAsync(LocatorScreenshotOptions? options = null)

Parameters

options LocatorScreenshotOptions

Call options

Returns

Task<byte[]>

ScrollIntoViewIfNeededAsync(LocatorScrollIntoViewIfNeededOptions?)

This method waits for actionability checks, then tries to scroll element into view, unless it is completely visible as defined by IntersectionObserver's ratio.

See scrolling for alternative ways to scroll.

Task ScrollIntoViewIfNeededAsync(LocatorScrollIntoViewIfNeededOptions? options = null)

Parameters

options LocatorScrollIntoViewIfNeededOptions

Call options

Returns

Task

SelectOptionAsync(IElementHandle, LocatorSelectOptionOptions?)

Selects option or options in <select>.

**Details**

This method waits for actionability checks, waits until all specified options are present in the <select> element and selects these options.

If the target element is not a <select> element, this method throws an error. However, if the element is inside the <label> element that has an associated control, the control will be used instead.

Returns the array of option values that have been successfully selected.

Triggers a change and input event once all the provided options have been selected.

**Usage**

// single selection matching the value or label
await element.SelectOptionAsync(new[] { "blue" });
// single selection matching the label
await element.SelectOptionAsync(new[] { new SelectOptionValue() { Label = "blue" } });
// multiple selection for blue, red and second option
await element.SelectOptionAsync(new[] { "red", "green", "blue" });
Task<IReadOnlyList<string>> SelectOptionAsync(IElementHandle values, LocatorSelectOptionOptions? options = null)

Parameters

values IElementHandle

Options to select. If the <select> has the multiple attribute, all matching options are selected, otherwise only the first option matching one of the passed options is selected. String values are matching both values and labels. Option is considered matching if all specified properties match.

options LocatorSelectOptionOptions

Call options

Returns

Task<IReadOnlyList<string>>

SelectOptionAsync(SelectOptionValue, LocatorSelectOptionOptions?)

Selects option or options in <select>.

**Details**

This method waits for actionability checks, waits until all specified options are present in the <select> element and selects these options.

If the target element is not a <select> element, this method throws an error. However, if the element is inside the <label> element that has an associated control, the control will be used instead.

Returns the array of option values that have been successfully selected.

Triggers a change and input event once all the provided options have been selected.

**Usage**

// single selection matching the value or label
await element.SelectOptionAsync(new[] { "blue" });
// single selection matching the label
await element.SelectOptionAsync(new[] { new SelectOptionValue() { Label = "blue" } });
// multiple selection for blue, red and second option
await element.SelectOptionAsync(new[] { "red", "green", "blue" });
Task<IReadOnlyList<string>> SelectOptionAsync(SelectOptionValue values, LocatorSelectOptionOptions? options = null)

Parameters

values SelectOptionValue

Options to select. If the <select> has the multiple attribute, all matching options are selected, otherwise only the first option matching one of the passed options is selected. String values are matching both values and labels. Option is considered matching if all specified properties match.

options LocatorSelectOptionOptions

Call options

Returns

Task<IReadOnlyList<string>>

SelectOptionAsync(IEnumerable<IElementHandle>, LocatorSelectOptionOptions?)

Selects option or options in <select>.

**Details**

This method waits for actionability checks, waits until all specified options are present in the <select> element and selects these options.

If the target element is not a <select> element, this method throws an error. However, if the element is inside the <label> element that has an associated control, the control will be used instead.

Returns the array of option values that have been successfully selected.

Triggers a change and input event once all the provided options have been selected.

**Usage**

// single selection matching the value or label
await element.SelectOptionAsync(new[] { "blue" });
// single selection matching the label
await element.SelectOptionAsync(new[] { new SelectOptionValue() { Label = "blue" } });
// multiple selection for blue, red and second option
await element.SelectOptionAsync(new[] { "red", "green", "blue" });
Task<IReadOnlyList<string>> SelectOptionAsync(IEnumerable<IElementHandle> values, LocatorSelectOptionOptions? options = null)

Parameters

values IEnumerable<IElementHandle>

Options to select. If the <select> has the multiple attribute, all matching options are selected, otherwise only the first option matching one of the passed options is selected. String values are matching both values and labels. Option is considered matching if all specified properties match.

options LocatorSelectOptionOptions

Call options

Returns

Task<IReadOnlyList<string>>

SelectOptionAsync(IEnumerable<SelectOptionValue>, LocatorSelectOptionOptions?)

Selects option or options in <select>.

**Details**

This method waits for actionability checks, waits until all specified options are present in the <select> element and selects these options.

If the target element is not a <select> element, this method throws an error. However, if the element is inside the <label> element that has an associated control, the control will be used instead.

Returns the array of option values that have been successfully selected.

Triggers a change and input event once all the provided options have been selected.

**Usage**

// single selection matching the value or label
await element.SelectOptionAsync(new[] { "blue" });
// single selection matching the label
await element.SelectOptionAsync(new[] { new SelectOptionValue() { Label = "blue" } });
// multiple selection for blue, red and second option
await element.SelectOptionAsync(new[] { "red", "green", "blue" });
Task<IReadOnlyList<string>> SelectOptionAsync(IEnumerable<SelectOptionValue> values, LocatorSelectOptionOptions? options = null)

Parameters

values IEnumerable<SelectOptionValue>

Options to select. If the <select> has the multiple attribute, all matching options are selected, otherwise only the first option matching one of the passed options is selected. String values are matching both values and labels. Option is considered matching if all specified properties match.

options LocatorSelectOptionOptions

Call options

Returns

Task<IReadOnlyList<string>>

SelectOptionAsync(IEnumerable<string>, LocatorSelectOptionOptions?)

Selects option or options in <select>.

**Details**

This method waits for actionability checks, waits until all specified options are present in the <select> element and selects these options.

If the target element is not a <select> element, this method throws an error. However, if the element is inside the <label> element that has an associated control, the control will be used instead.

Returns the array of option values that have been successfully selected.

Triggers a change and input event once all the provided options have been selected.

**Usage**

// single selection matching the value or label
await element.SelectOptionAsync(new[] { "blue" });
// single selection matching the label
await element.SelectOptionAsync(new[] { new SelectOptionValue() { Label = "blue" } });
// multiple selection for blue, red and second option
await element.SelectOptionAsync(new[] { "red", "green", "blue" });
Task<IReadOnlyList<string>> SelectOptionAsync(IEnumerable<string> values, LocatorSelectOptionOptions? options = null)

Parameters

values IEnumerable<string>

Options to select. If the <select> has the multiple attribute, all matching options are selected, otherwise only the first option matching one of the passed options is selected. String values are matching both values and labels. Option is considered matching if all specified properties match.

options LocatorSelectOptionOptions

Call options

Returns

Task<IReadOnlyList<string>>

SelectOptionAsync(string, LocatorSelectOptionOptions?)

Selects option or options in <select>.

**Details**

This method waits for actionability checks, waits until all specified options are present in the <select> element and selects these options.

If the target element is not a <select> element, this method throws an error. However, if the element is inside the <label> element that has an associated control, the control will be used instead.

Returns the array of option values that have been successfully selected.

Triggers a change and input event once all the provided options have been selected.

**Usage**

// single selection matching the value or label
await element.SelectOptionAsync(new[] { "blue" });
// single selection matching the label
await element.SelectOptionAsync(new[] { new SelectOptionValue() { Label = "blue" } });
// multiple selection for blue, red and second option
await element.SelectOptionAsync(new[] { "red", "green", "blue" });
Task<IReadOnlyList<string>> SelectOptionAsync(string values, LocatorSelectOptionOptions? options = null)

Parameters

values string

Options to select. If the <select> has the multiple attribute, all matching options are selected, otherwise only the first option matching one of the passed options is selected. String values are matching both values and labels. Option is considered matching if all specified properties match.

options LocatorSelectOptionOptions

Call options

Returns

Task<IReadOnlyList<string>>

SelectTextAsync(LocatorSelectTextOptions?)

This method waits for actionability checks, then focuses the element and selects all its text content.

If the element is inside the <label> element that has an associated control, focuses and selects text in the control instead.

Task SelectTextAsync(LocatorSelectTextOptions? options = null)

Parameters

options LocatorSelectTextOptions

Call options

Returns

Task

SetCheckedAsync(bool, LocatorSetCheckedOptions?)

Set the state of a checkbox or a radio element.

**Usage**

await page.GetByRole(AriaRole.Checkbox).SetCheckedAsync(true);

**Details**

This method checks or unchecks an element by performing the following steps:

When all steps combined have not finished during the specified timeout, this method throws a TimeoutException. Passing zero timeout disables this.

Task SetCheckedAsync(bool checkedState, LocatorSetCheckedOptions? options = null)

Parameters

checkedState bool

Whether to check or uncheck the checkbox.

options LocatorSetCheckedOptions

Call options

Returns

Task

SetInputFilesAsync(FilePayload, LocatorSetInputFilesOptions?)

Upload file or multiple files into <input type=file>. For inputs with a [webkitdirectory] attribute, only a single directory path is supported.

**Usage**

// Select one file
await page.GetByLabel("Upload file").SetInputFilesAsync("myfile.pdf");

// Select multiple files await page.GetByLabel("Upload files").SetInputFilesAsync(new[] { "file1.txt", "file12.txt" });

// Select a directory await page.GetByLabel("Upload directory").SetInputFilesAsync("mydir");

// Remove all the selected files await page.GetByLabel("Upload file").SetInputFilesAsync(new[] {});

// Upload buffer from memory await page.GetByLabel("Upload file").SetInputFilesAsync(new FilePayload { Name = "file.txt", MimeType = "text/plain", Buffer = System.Text.Encoding.UTF8.GetBytes("this is a test"), });

**Details**

Sets the value of the file input to these file paths or files. If some of the filePaths are relative paths, then they are resolved relative to the current working directory. For empty array, clears the selected files.

This method expects ILocator to point to an input element. However, if the element is inside the <label> element that has an associated control, targets the control instead.

Task SetInputFilesAsync(FilePayload files, LocatorSetInputFilesOptions? options = null)

Parameters

files FilePayload
options LocatorSetInputFilesOptions

Call options

Returns

Task

SetInputFilesAsync(IEnumerable<FilePayload>, LocatorSetInputFilesOptions?)

Upload file or multiple files into <input type=file>. For inputs with a [webkitdirectory] attribute, only a single directory path is supported.

**Usage**

// Select one file
await page.GetByLabel("Upload file").SetInputFilesAsync("myfile.pdf");

// Select multiple files await page.GetByLabel("Upload files").SetInputFilesAsync(new[] { "file1.txt", "file12.txt" });

// Select a directory await page.GetByLabel("Upload directory").SetInputFilesAsync("mydir");

// Remove all the selected files await page.GetByLabel("Upload file").SetInputFilesAsync(new[] {});

// Upload buffer from memory await page.GetByLabel("Upload file").SetInputFilesAsync(new FilePayload { Name = "file.txt", MimeType = "text/plain", Buffer = System.Text.Encoding.UTF8.GetBytes("this is a test"), });

**Details**

Sets the value of the file input to these file paths or files. If some of the filePaths are relative paths, then they are resolved relative to the current working directory. For empty array, clears the selected files.

This method expects ILocator to point to an input element. However, if the element is inside the <label> element that has an associated control, targets the control instead.

Task SetInputFilesAsync(IEnumerable<FilePayload> files, LocatorSetInputFilesOptions? options = null)

Parameters

files IEnumerable<FilePayload>
options LocatorSetInputFilesOptions

Call options

Returns

Task

SetInputFilesAsync(IEnumerable<string>, LocatorSetInputFilesOptions?)

Upload file or multiple files into <input type=file>. For inputs with a [webkitdirectory] attribute, only a single directory path is supported.

**Usage**

// Select one file
await page.GetByLabel("Upload file").SetInputFilesAsync("myfile.pdf");

// Select multiple files await page.GetByLabel("Upload files").SetInputFilesAsync(new[] { "file1.txt", "file12.txt" });

// Select a directory await page.GetByLabel("Upload directory").SetInputFilesAsync("mydir");

// Remove all the selected files await page.GetByLabel("Upload file").SetInputFilesAsync(new[] {});

// Upload buffer from memory await page.GetByLabel("Upload file").SetInputFilesAsync(new FilePayload { Name = "file.txt", MimeType = "text/plain", Buffer = System.Text.Encoding.UTF8.GetBytes("this is a test"), });

**Details**

Sets the value of the file input to these file paths or files. If some of the filePaths are relative paths, then they are resolved relative to the current working directory. For empty array, clears the selected files.

This method expects ILocator to point to an input element. However, if the element is inside the <label> element that has an associated control, targets the control instead.

Task SetInputFilesAsync(IEnumerable<string> files, LocatorSetInputFilesOptions? options = null)

Parameters

files IEnumerable<string>
options LocatorSetInputFilesOptions

Call options

Returns

Task

SetInputFilesAsync(string, LocatorSetInputFilesOptions?)

Upload file or multiple files into <input type=file>. For inputs with a [webkitdirectory] attribute, only a single directory path is supported.

**Usage**

// Select one file
await page.GetByLabel("Upload file").SetInputFilesAsync("myfile.pdf");

// Select multiple files await page.GetByLabel("Upload files").SetInputFilesAsync(new[] { "file1.txt", "file12.txt" });

// Select a directory await page.GetByLabel("Upload directory").SetInputFilesAsync("mydir");

// Remove all the selected files await page.GetByLabel("Upload file").SetInputFilesAsync(new[] {});

// Upload buffer from memory await page.GetByLabel("Upload file").SetInputFilesAsync(new FilePayload { Name = "file.txt", MimeType = "text/plain", Buffer = System.Text.Encoding.UTF8.GetBytes("this is a test"), });

**Details**

Sets the value of the file input to these file paths or files. If some of the filePaths are relative paths, then they are resolved relative to the current working directory. For empty array, clears the selected files.

This method expects ILocator to point to an input element. However, if the element is inside the <label> element that has an associated control, targets the control instead.

Task SetInputFilesAsync(string files, LocatorSetInputFilesOptions? options = null)

Parameters

files string
options LocatorSetInputFilesOptions

Call options

Returns

Task

TapAsync(LocatorTapOptions?)

Perform a tap gesture on the element matching the locator.

**Details**

This method taps the element by performing the following steps:

If the element is detached from the DOM at any moment during the action, this method throws.

When all steps combined have not finished during the specified timeout, this method throws a TimeoutException. Passing zero timeout disables this.

Task TapAsync(LocatorTapOptions? options = null)

Parameters

options LocatorTapOptions

Call options

Returns

Task

Remarks

element.tap() requires that the hasTouch option of the browser context be set to true.

TextContentAsync(LocatorTextContentOptions?)

Returns the node.textContent.

Task<string?> TextContentAsync(LocatorTextContentOptions? options = null)

Parameters

options LocatorTextContentOptions

Call options

Returns

Task<string>

Remarks

If you need to assert text on the page, prefer ToHaveTextAsync(string, LocatorAssertionsToHaveTextOptions?) to avoid flakiness. See assertions guide for more details.

TypeAsync(string, LocatorTypeOptions?)

**DEPRECATED** In most cases, you should use FillAsync(string, LocatorFillOptions?) instead. You only need to press keys one by one if there is special keyboard handling on the page - in this case use PressSequentiallyAsync(string, LocatorPressSequentiallyOptions?).

Focuses the element, and then sends a keydown, keypress/input, and keyup event for each character in the text.

To press a special key, like Control or ArrowDown, use PressAsync(string, LocatorPressOptions?).

**Usage**

[Obsolete]
Task TypeAsync(string text, LocatorTypeOptions? options = null)

Parameters

text string

A text to type into a focused element.

options LocatorTypeOptions

Call options

Returns

Task

UncheckAsync(LocatorUncheckOptions?)

Ensure that checkbox or radio element is unchecked.

**Usage**

await page.GetByRole(AriaRole.Checkbox).UncheckAsync();

**Details**

This method unchecks the element by performing the following steps:

If the element is detached from the DOM at any moment during the action, this method throws.

When all steps combined have not finished during the specified timeout, this method throws a TimeoutException. Passing zero timeout disables this.

Task UncheckAsync(LocatorUncheckOptions? options = null)

Parameters

options LocatorUncheckOptions

Call options

Returns

Task

WaitForAsync(LocatorWaitForOptions?)

Returns when element specified by locator satisfies the state option.

If target element already satisfies the condition, the method returns immediately. Otherwise, waits for up to timeout milliseconds until the condition is met.

**Usage**

var orderSent = page.Locator("#order-sent");
orderSent.WaitForAsync();
Task WaitForAsync(LocatorWaitForOptions? options = null)

Parameters

options LocatorWaitForOptions

Call options

Returns

Task