Screen
Namespace: E2E
public class ScreenSemantic queries against the current screen. An action or a single-node assertion fails when the query matches more than one node. Narrow it with Filter(TextMatch), First(), Last(), or Nth(int).
Inheritance: object
Derived: FrameScreen
Methods
Section titled “Methods”DebugAsync(ActionOptions?, CancellationToken)
Section titled “DebugAsync(ActionOptions?, CancellationToken)”public Task DebugAsync(ActionOptions? options = null, CancellationToken cancellationToken = default)Prints CancellationToken) to Out, which NUnit and xUnit v2 capture into the test’s output.
xUnit v3 shows it only when the test assembly has [assembly: CaptureConsole].
Parameters
| Name | Type | Description |
|---|---|---|
options |
ActionOptions | |
cancellationToken |
CancellationToken |
Returns: Task
GetByDisplayValue(TextMatch, TextMatchOptions)
Section titled “GetByDisplayValue(TextMatch, TextMatchOptions)”public Locator GetByDisplayValue(TextMatch value, TextMatchOptions options)Creates a lazy displayed-value query: the current value of an input, text area, or select. A checkbox or radio never shows its value, so it never matches.
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 lazy displayed-value query: the current value of an input, text area, or select. A checkbox or radio never shows its value, so it never matches.
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 lazy accessible-label query: any node whose accessible name matches.
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 lazy accessible-label query: any node whose accessible name matches.
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 lazy placeholder query.
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 lazy placeholder query.
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 lazy role query narrowed by name, states, or heading level.
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 lazy role query narrowed to an accessible name and the given options.
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 lazy role query. img is read as image. A role query never matches a hidden node.
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 lazy test-id query. A string matches the whole id, case-sensitive.
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 lazy test-id query. A string matches the whole id, case-sensitive; Exact is ignored.
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 lazy visible-text query. It answers with the innermost match, such as a
<strong> inside a paragraph. Text inside a control’s label answers with the control.
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 lazy visible-text query. It answers with the innermost match, such as a
<strong> inside a paragraph. Text inside a control’s label answers with the control.
Parameters
| Name | Type | Description |
|---|---|---|
text |
TextMatch | |
exact |
bool |
Returns: Locator
ScrollUntilVisibleAsync(Locator, ScrollUntilVisibleOptions?, CancellationToken)
Section titled “ScrollUntilVisibleAsync(Locator, ScrollUntilVisibleOptions?, CancellationToken)”public Task ScrollUntilVisibleAsync(Locator target, ScrollUntilVisibleOptions? options = null, CancellationToken cancellationToken = default)Scrolls the viewport until <code class=“paramref”>target</code> is visible: polls the target and swipes between polls, down and slowly
unless ScrollUntilVisibleOptions say otherwise. Every swipe is bounded by the scroll’s own deadline, not the
action timeout. Upstream’s screen.scrollUntilVisible.
Parameters
| Name | Type | Description |
|---|---|---|
target |
Locator | |
options |
ScrollUntilVisibleOptions | |
cancellationToken |
CancellationToken |
Returns: Task
Exceptions
| Type | Condition |
|---|---|
| TestException | LOCATOR_NOT_FOUND when the target did not become visible in time; INVALID_LOCATOR when it belongs to another screen or attempt. |
TreeAsync(ActionOptions?, CancellationToken)
Section titled “TreeAsync(ActionOptions?, CancellationToken)”public Task<string> TreeAsync(ActionOptions? options = null, CancellationToken cancellationToken = default)Reads the whole screen once, without waiting, as the agent reads it: one node per line, #id role "name" text="…" [states],
children indented, secrets redacted. The text has the format and size limit of the trace’s screen at failure. A node the page does
not show is left out. Use it to write a locator. Takes Timeout, the configured action timeout by default.
Parameters
| Name | Type | Description |
|---|---|---|
options |
ActionOptions | |
cancellationToken |
CancellationToken |
Returns: Task<string>