Skip to content

Screen

Namespace: E2E

public class Screen

Semantic 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

View source

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

View source

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

View source

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

View source

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

View source

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

View source

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

View source

public Locator GetByPlaceholder(TextMatch placeholder, bool exact = true)

Creates a lazy placeholder query.

Parameters

Name Type Description
placeholder TextMatch
exact bool

Returns: Locator

View source

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

View source

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

View source

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

View source

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

View source

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

View source

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

View source

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

View source

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.

View source

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>

View source