Locator
Namespace: E2E
public sealed class LocatorA query that resolves against a fresh observation every time it is used.
Inheritance: object
Methods
Section titled “Methods”AllAsync(CancellationToken)
Section titled “AllAsync(CancellationToken)”public Task<IReadOnlyList<Locator>> AllAsync(CancellationToken cancellationToken = default)One Nth(int) locator per current match, without waiting. Empty when nothing matches.
Parameters
| Name | Type | Description |
|---|---|---|
cancellationToken |
CancellationToken |
Returns: Task<IReadOnlyList<Locator>>
AllTextContentsAsync(CancellationToken)
Section titled “AllTextContentsAsync(CancellationToken)”public Task<IReadOnlyList<string>> AllTextContentsAsync(CancellationToken cancellationToken = default)Reads the whitespace-normalized rendered text of every current match, without waiting. Empty when nothing matches.
Fails with POLICY_DENIED when any match is a secure field.
Parameters
| Name | Type | Description |
|---|---|---|
cancellationToken |
CancellationToken |
Returns: Task<IReadOnlyList<string>>
BoundingBoxAsync(CancellationToken)
Section titled “BoundingBoxAsync(CancellationToken)”public Task<BoundingBox?> BoundingBoxAsync(CancellationToken cancellationToken = default)Waits up to the action timeout for one match, then reads its viewport-relative box once, or null when the node lays out no box
(display: none on it or an ancestor, or any display: contents element) or the engine does not report one.
Parameters
| Name | Type | Description |
|---|---|---|
cancellationToken |
CancellationToken |
Returns: Task<BoundingBox>
CheckAsync(ActionOptions?, CancellationToken)
Section titled “CheckAsync(ActionOptions?, CancellationToken)”public Task CheckAsync(ActionOptions? options = null, CancellationToken cancellationToken = default)Parameters
| Name | Type | Description |
|---|---|---|
options |
ActionOptions | |
cancellationToken |
CancellationToken |
Returns: Task
ClearAsync(ActionOptions?, CancellationToken)
Section titled “ClearAsync(ActionOptions?, CancellationToken)”public Task ClearAsync(ActionOptions? options = null, CancellationToken cancellationToken = default)Parameters
| Name | Type | Description |
|---|---|---|
options |
ActionOptions | |
cancellationToken |
CancellationToken |
Returns: Task
ClickAsync(ActionOptions?, CancellationToken)
Section titled “ClickAsync(ActionOptions?, CancellationToken)”public Task ClickAsync(ActionOptions? options = null, CancellationToken cancellationToken = default)Alias of CancellationToken).
Parameters
| Name | Type | Description |
|---|---|---|
options |
ActionOptions | |
cancellationToken |
CancellationToken |
Returns: Task
CountAsync(CancellationToken)
Section titled “CountAsync(CancellationToken)”public Task<int> CountAsync(CancellationToken cancellationToken = default)Counts current matches without waiting.
Parameters
| Name | Type | Description |
|---|---|---|
cancellationToken |
CancellationToken |
Returns: Task<int>
DblClickAsync(ActionOptions?, CancellationToken)
Section titled “DblClickAsync(ActionOptions?, CancellationToken)”public Task DblClickAsync(ActionOptions? options = null, CancellationToken cancellationToken = default)Alias of CancellationToken).
Parameters
| Name | Type | Description |
|---|---|---|
options |
ActionOptions | |
cancellationToken |
CancellationToken |
Returns: Task
DoubleTapAsync(ActionOptions?, CancellationToken)
Section titled “DoubleTapAsync(ActionOptions?, CancellationToken)”public Task DoubleTapAsync(ActionOptions? options = null, CancellationToken cancellationToken = default)Parameters
| Name | Type | Description |
|---|---|---|
options |
ActionOptions | |
cancellationToken |
CancellationToken |
Returns: Task
FillAsync(Secret, ActionOptions?, CancellationToken)
Section titled “FillAsync(Secret, ActionOptions?, CancellationToken)”public Task FillAsync(Secret value, ActionOptions? options = null, CancellationToken cancellationToken = default)Fills a secret. The engine marks the value sensitive and never reports it.
Parameters
| Name | Type | Description |
|---|---|---|
value |
Secret | |
options |
ActionOptions | |
cancellationToken |
CancellationToken |
Returns: Task
FillAsync(string, ActionOptions?, CancellationToken)
Section titled “FillAsync(string, ActionOptions?, CancellationToken)”public Task FillAsync(string value, ActionOptions? options = null, CancellationToken cancellationToken = default)Parameters
| Name | Type | Description |
|---|---|---|
value |
string | |
options |
ActionOptions | |
cancellationToken |
CancellationToken |
Returns: Task
Filter(Locator)
Section titled “Filter(Locator)”public Locator Filter(Locator has)Keeps the matches with a descendant that <code class=“paramref”>has</code> matches. <code class=“paramref”>has</code> resolves inside each match.
Parameters
| Name | Type | Description |
|---|---|---|
has |
Locator |
Returns: Locator
Filter(TextMatch)
Section titled “Filter(TextMatch)”public Locator Filter(TextMatch hasText)Keeps the matches whose own or descendants’ name, text, or value contains <code class=“paramref”>hasText</code>, ignoring case.
Parameters
| Name | Type | Description |
|---|---|---|
hasText |
TextMatch |
Returns: Locator
First()
Section titled “First()”public Locator First()Returns: Locator
FocusAsync(ActionOptions?, CancellationToken)
Section titled “FocusAsync(ActionOptions?, CancellationToken)”public Task FocusAsync(ActionOptions? options = null, CancellationToken cancellationToken = default)Parameters
| Name | Type | Description |
|---|---|---|
options |
ActionOptions | |
cancellationToken |
CancellationToken |
Returns: Task
GetAttributeAsync(string, CancellationToken)
Section titled “GetAttributeAsync(string, CancellationToken)”public Task<string?> GetAttributeAsync(string name, CancellationToken cancellationToken = default)Waits up to the action timeout for one match, then reads one platform attribute once, or null when the node does not have it. Fails with POLICY_DENIED on a secure field.
Parameters
| Name | Type | Description |
|---|---|---|
name |
string | |
cancellationToken |
CancellationToken |
Returns: Task<string>
GetByDisplayValue(TextMatch, TextMatchOptions)
Section titled “GetByDisplayValue(TextMatch, TextMatchOptions)”public Locator GetByDisplayValue(TextMatch value, TextMatchOptions options)Creates a displayed-value query among this locator’s descendants.
Parameters
| Name | Type | Description |
|---|---|---|
value |
TextMatch | |
options |
TextMatchOptions |
Returns: Locator
GetByDisplayValue(TextMatch, bool)
Section titled “GetByDisplayValue(TextMatch, bool)”public Locator GetByDisplayValue(TextMatch value, bool exact = true)Creates a displayed-value query among this locator’s descendants.
Parameters
| Name | Type | Description |
|---|---|---|
value |
TextMatch | |
exact |
bool |
Returns: Locator
GetByLabel(TextMatch, TextMatchOptions)
Section titled “GetByLabel(TextMatch, TextMatchOptions)”public Locator GetByLabel(TextMatch label, TextMatchOptions options)Creates a label query among this locator’s descendants.
Parameters
| Name | Type | Description |
|---|---|---|
label |
TextMatch | |
options |
TextMatchOptions |
Returns: Locator
GetByLabel(TextMatch, bool)
Section titled “GetByLabel(TextMatch, bool)”public Locator GetByLabel(TextMatch label, bool exact = true)Creates a label query among this locator’s descendants.
Parameters
| Name | Type | Description |
|---|---|---|
label |
TextMatch | |
exact |
bool |
Returns: Locator
GetByPlaceholder(TextMatch, TextMatchOptions)
Section titled “GetByPlaceholder(TextMatch, TextMatchOptions)”public Locator GetByPlaceholder(TextMatch placeholder, TextMatchOptions options)Creates a placeholder query among this locator’s descendants.
Parameters
| Name | Type | Description |
|---|---|---|
placeholder |
TextMatch | |
options |
TextMatchOptions |
Returns: Locator
GetByPlaceholder(TextMatch, bool)
Section titled “GetByPlaceholder(TextMatch, bool)”public Locator GetByPlaceholder(TextMatch placeholder, bool exact = true)Creates a placeholder query among this locator’s descendants.
Parameters
| Name | Type | Description |
|---|---|---|
placeholder |
TextMatch | |
exact |
bool |
Returns: Locator
GetByRole(string, RoleOptions)
Section titled “GetByRole(string, RoleOptions)”public Locator GetByRole(string role, RoleOptions options)Creates a role query among this locator’s descendants.
Parameters
| Name | Type | Description |
|---|---|---|
role |
string | |
options |
RoleOptions |
Returns: Locator
GetByRole(string, TextMatch, RoleOptions)
Section titled “GetByRole(string, TextMatch, RoleOptions)”public Locator GetByRole(string role, TextMatch name, RoleOptions options)Creates a role query among this locator’s descendants.
Parameters
| Name | Type | Description |
|---|---|---|
role |
string | |
name |
TextMatch | |
options |
RoleOptions |
Returns: Locator
GetByRole(string, TextMatch?, bool)
Section titled “GetByRole(string, TextMatch?, bool)”public Locator GetByRole(string role, TextMatch? name = null, bool exact = true)Creates a role query among this locator’s descendants.
Parameters
| Name | Type | Description |
|---|---|---|
role |
string | |
name |
TextMatch | |
exact |
bool |
Returns: Locator
GetByTestId(TextMatch)
Section titled “GetByTestId(TextMatch)”public Locator GetByTestId(TextMatch testId)Creates a test-id query among this locator’s descendants.
Parameters
| Name | Type | Description |
|---|---|---|
testId |
TextMatch |
Returns: Locator
GetByTestId(TextMatch, TextMatchOptions)
Section titled “GetByTestId(TextMatch, TextMatchOptions)”public Locator GetByTestId(TextMatch testId, TextMatchOptions options)Creates a test-id query among this locator’s descendants.
Parameters
| Name | Type | Description |
|---|---|---|
testId |
TextMatch | |
options |
TextMatchOptions |
Returns: Locator
GetByText(TextMatch, TextMatchOptions)
Section titled “GetByText(TextMatch, TextMatchOptions)”public Locator GetByText(TextMatch text, TextMatchOptions options)Creates a visible-text query among this locator’s descendants.
Parameters
| Name | Type | Description |
|---|---|---|
text |
TextMatch | |
options |
TextMatchOptions |
Returns: Locator
GetByText(TextMatch, bool)
Section titled “GetByText(TextMatch, bool)”public Locator GetByText(TextMatch text, bool exact = true)Creates a visible-text query among this locator’s descendants.
Parameters
| Name | Type | Description |
|---|---|---|
text |
TextMatch | |
exact |
bool |
Returns: Locator
InputValueAsync(CancellationToken)
Section titled “InputValueAsync(CancellationToken)”public Task<string> InputValueAsync(CancellationToken cancellationToken = default)Waits up to the action timeout for one match, then reads an input value once, the empty string when the node has none. Does not retry for a value and does not verify an earlier act. A checkbox or
radio reads its value attribute, on when it has none, whatever its checked state. Fails with
POLICY_DENIED on a secure field.
Parameters
| Name | Type | Description |
|---|---|---|
cancellationToken |
CancellationToken |
Returns: Task<string>
IsCheckedAsync(CancellationToken)
Section titled “IsCheckedAsync(CancellationToken)”public Task<bool> IsCheckedAsync(CancellationToken cancellationToken = default)Waits up to the action timeout for one match, then reads its checked state once.
Parameters
| Name | Type | Description |
|---|---|---|
cancellationToken |
CancellationToken |
Returns: Task<bool>
IsDisabledAsync(CancellationToken)
Section titled “IsDisabledAsync(CancellationToken)”public Task<bool> IsDisabledAsync(CancellationToken cancellationToken = default)Waits up to the action timeout for one match, then reads its disabled state once, the negation of IsEnabledAsync(CancellationToken).
Parameters
| Name | Type | Description |
|---|---|---|
cancellationToken |
CancellationToken |
Returns: Task<bool>
IsEnabledAsync(CancellationToken)
Section titled “IsEnabledAsync(CancellationToken)”public Task<bool> IsEnabledAsync(CancellationToken cancellationToken = default)Waits up to the action timeout for one match, then reads its enabled state once.
Parameters
| Name | Type | Description |
|---|---|---|
cancellationToken |
CancellationToken |
Returns: Task<bool>
IsHiddenAsync(CancellationToken)
Section titled “IsHiddenAsync(CancellationToken)”public Task<bool> IsHiddenAsync(CancellationToken cancellationToken = default)Reads current hidden or absent state, the negation of IsVisibleAsync(CancellationToken).
Parameters
| Name | Type | Description |
|---|---|---|
cancellationToken |
CancellationToken |
Returns: Task<bool>
IsVisibleAsync(CancellationToken)
Section titled “IsVisibleAsync(CancellationToken)”public Task<bool> IsVisibleAsync(CancellationToken cancellationToken = default)Reads current visibility: true when exactly one visible node matches. More than one match fails.
Parameters
| Name | Type | Description |
|---|---|---|
cancellationToken |
CancellationToken |
Returns: Task<bool>
Last()
Section titled “Last()”public Locator Last()Returns: Locator
Nth(int)
Section titled “Nth(int)”public Locator Nth(int index)Parameters
| Name | Type | Description |
|---|---|---|
index |
int |
Returns: Locator
Or(Locator)
Section titled “Or(Locator)”public Locator Or(Locator other)Matches either locator, preserving document order without duplicate nodes. a.Or(b) stays strict: when both match
different nodes, an action fails with STRICT_MODE, so add First() if either will do. Both locators must come
from the same screen and attempt. Upstream’s locator.or.
Parameters
| Name | Type | Description |
|---|---|---|
other |
Locator |
Returns: Locator
Exceptions
| Type | Condition |
|---|---|
| TestException | INVALID_LOCATOR: <code class=“paramref”>other</code> belongs to another screen or attempt. |
PressAsync(string, ActionOptions?, CancellationToken)
Section titled “PressAsync(string, ActionOptions?, CancellationToken)”public Task PressAsync(string key, ActionOptions? options = null, CancellationToken cancellationToken = default)Parameters
| Name | Type | Description |
|---|---|---|
key |
string | |
options |
ActionOptions | |
cancellationToken |
CancellationToken |
Returns: Task
PressSequentiallyAsync(string, PressSequentiallyOptions?, CancellationToken)
Section titled “PressSequentiallyAsync(string, PressSequentiallyOptions?, CancellationToken)”public Task PressSequentiallyAsync(string text, PressSequentiallyOptions? options = null, CancellationToken cancellationToken = default)Focuses the input and types <code class=“paramref”>text</code> one character at a time, so the app receives key events. Delay waits between characters.
Parameters
| Name | Type | Description |
|---|---|---|
text |
string | |
options |
PressSequentiallyOptions | |
cancellationToken |
CancellationToken |
Returns: Task
ScrollIntoViewAsync(ActionOptions?, CancellationToken)
Section titled “ScrollIntoViewAsync(ActionOptions?, CancellationToken)”public Task ScrollIntoViewAsync(ActionOptions? options = null, CancellationToken cancellationToken = default)Parameters
| Name | Type | Description |
|---|---|---|
options |
ActionOptions | |
cancellationToken |
CancellationToken |
Returns: Task
ScrollUntilVisibleAsync(Locator, ScrollUntilVisibleOptions?, CancellationToken)
Section titled “ScrollUntilVisibleAsync(Locator, ScrollUntilVisibleOptions?, CancellationToken)”public Task ScrollUntilVisibleAsync(Locator target, ScrollUntilVisibleOptions? options = null, CancellationToken cancellationToken = default)Scrolls this locator’s node until <code class=“paramref”>target</code> is visible: the node itself swipes, so a scroll container pages
without the pointer having to hover it first. Both locators must come from the same screen. Upstream’s locator.scrollUntilVisible.
Parameters
| Name | Type | Description |
|---|---|---|
target |
Locator | |
options |
ScrollUntilVisibleOptions | |
cancellationToken |
CancellationToken |
Returns: Task
SelectOptionAsync(string, ActionOptions?, CancellationToken)
Section titled “SelectOptionAsync(string, ActionOptions?, CancellationToken)”public Task SelectOptionAsync(string value, ActionOptions? options = null, CancellationToken cancellationToken = default)Selects the option whose value or label is <code class=“paramref”>value</code>.
Parameters
| Name | Type | Description |
|---|---|---|
value |
string | |
options |
ActionOptions | |
cancellationToken |
CancellationToken |
Returns: Task
TapAsync(ActionOptions?, CancellationToken)
Section titled “TapAsync(ActionOptions?, CancellationToken)”public Task TapAsync(ActionOptions? options = null, CancellationToken cancellationToken = default)Parameters
| Name | Type | Description |
|---|---|---|
options |
ActionOptions | |
cancellationToken |
CancellationToken |
Returns: Task
TextContentAsync(CancellationToken)
Section titled “TextContentAsync(CancellationToken)”public Task<string?> TextContentAsync(CancellationToken cancellationToken = default)Waits up to the action timeout for one match, then reads whitespace-normalized text once: the node’s rendered text (innerText on the web), not its label. Null when the node has no text.
Does not retry for a value and does not verify an earlier act. Fails with POLICY_DENIED on a secure field.
Parameters
| Name | Type | Description |
|---|---|---|
cancellationToken |
CancellationToken |
Returns: Task<string>
UncheckAsync(ActionOptions?, CancellationToken)
Section titled “UncheckAsync(ActionOptions?, CancellationToken)”public Task UncheckAsync(ActionOptions? options = null, CancellationToken cancellationToken = default)Parameters
| Name | Type | Description |
|---|---|---|
options |
ActionOptions | |
cancellationToken |
CancellationToken |
Returns: Task
WaitForAsync(LocatorWaitForOptions?, CancellationToken)
Section titled “WaitForAsync(LocatorWaitForOptions?, CancellationToken)”public Task WaitForAsync(LocatorWaitForOptions? options = null, CancellationToken cancellationToken = default)Waits for State, Visible by default:
Attached for one match, visible or not;
Detached for none; Hidden for none
or a hidden one. The timeout defaults to the action timeout. More than one match fails at once.
Does not verify an earlier act.
Parameters
| Name | Type | Description |
|---|---|---|
options |
LocatorWaitForOptions | |
cancellationToken |
CancellationToken |
Returns: Task