ElementExtensions Class

The user actions on the elements of a TestPage (see PageInput).

public static class ElementExtensions

Methods

NameDescription
CheckAsync(Element, CancellationToken)Checks the check box or the radio button with a click.
ClickAsync(Element, ClickOptions?, CancellationToken)Clicks the element at its center.
DoubleClickAsync(Element, CancellationToken)Double-clicks the element.
FillAsync(Element, string, CancellationToken)Replaces the value of the text field with a text typed with the keyboard, then leaves the field.
GetAccessibilitySnapshot(Element)Gets the accessibility tree of the element, as a YAML snapshot (the format of the ARIA snapshots of Playwright).
GetMarkup(Element, MarkupOptions?)Gets the HTML of the element, formatted for snapshots.
HoverAsync(Element, CancellationToken)Moves the mouse over the element.
SelectOptionAsync(Element, string[])Selects options of the select element by value.
TapAsync(Element, CancellationToken)Taps the element with a finger.
TypeAsync(Element, string, CancellationToken)Focuses the element with a click and types a text with the keyboard.
UncheckAsync(Element, CancellationToken)Unchecks the check box with a click.

CheckAsync(Element, CancellationToken)

ElementExtensions.cs

Checks the check box or the radio button with a click.

public static Task CheckAsync(this Element element, CancellationToken cancellationToken = default)

Parameters

element Element
The input element.
cancellationToken CancellationToken
A token to cancel the wait.

Returns

Task A task completed once the components are idle.

ClickAsync(Element, ClickOptions?, CancellationToken)

ElementExtensions.cs

Clicks the element at its center.

public static Task ClickAsync(this Element element, ClickOptions? options = null, CancellationToken cancellationToken = default)

Parameters

element Element
The element.
options ClickOptions?
The options, or null for the default options.
cancellationToken CancellationToken
A token to cancel the wait.

Returns

Task A task completed once the components are idle.

DoubleClickAsync(Element, CancellationToken)

ElementExtensions.cs

Double-clicks the element.

public static Task DoubleClickAsync(this Element element, CancellationToken cancellationToken = default)

Parameters

element Element
The element.
cancellationToken CancellationToken
A token to cancel the wait.

Returns

Task A task completed once the components are idle.

FillAsync(Element, string, CancellationToken)

ElementExtensions.cs

Replaces the value of the text field with a text typed with the keyboard, then leaves the field.

public static Task FillAsync(this Element element, string text, CancellationToken cancellationToken = default)

Parameters

element Element
The text field.
text string
The text.
cancellationToken CancellationToken
A token to cancel the wait.

Returns

Task A task completed once the components are idle.

GetAccessibilitySnapshot(Element)

ElementExtensions.cs

Gets the accessibility tree of the element, as a YAML snapshot (the format of the ARIA snapshots of Playwright).

public static string GetAccessibilitySnapshot(this Element element)

Parameters

element Element
The element.

Returns

string The snapshot.

GetMarkup(Element, MarkupOptions?)

ElementExtensions.cs

Gets the HTML of the element, formatted for snapshots.

public static string GetMarkup(this Element element, MarkupOptions? options = null)

Parameters

element Element
The element.
options MarkupOptions?
The options, or null for the default options.

Returns

string The HTML.

HoverAsync(Element, CancellationToken)

ElementExtensions.cs

Moves the mouse over the element.

public static Task HoverAsync(this Element element, CancellationToken cancellationToken = default)

Parameters

element Element
The element.
cancellationToken CancellationToken
A token to cancel the wait.

Returns

Task A task completed once the components are idle.

SelectOptionAsync(Element, string[])

ElementExtensions.cs

Selects options of the select element by value.

public static Task SelectOptionAsync(this Element element, params string[] values)

Parameters

element Element
The select element.
values string[]
The values of the options to select.

Returns

Task A task completed once the components are idle.

TapAsync(Element, CancellationToken)

ElementExtensions.cs

Taps the element with a finger.

public static Task TapAsync(this Element element, CancellationToken cancellationToken = default)

Parameters

element Element
The element.
cancellationToken CancellationToken
A token to cancel the wait.

Returns

Task A task completed once the components are idle.

TypeAsync(Element, string, CancellationToken)

ElementExtensions.cs

Focuses the element with a click and types a text with the keyboard.

public static Task TypeAsync(this Element element, string text, CancellationToken cancellationToken = default)

Parameters

element Element
The element.
text string
The text.
cancellationToken CancellationToken
A token to cancel the wait.

Returns

Task A task completed once the components are idle.

UncheckAsync(Element, CancellationToken)

ElementExtensions.cs

Unchecks the check box with a click.

public static Task UncheckAsync(this Element element, CancellationToken cancellationToken = default)

Parameters

element Element
The input element.
cancellationToken CancellationToken
A token to cancel the wait.

Returns

Task A task completed once the components are idle.