PageInput Class
Plays the user of the page: the mouse, the keyboard and the touch screen. The input is dispatched as trusted events with the default actions of a browser (focus, text input, clicks, form submission, scrolling, drag and drop); the pointer targets the element under the pointer (hit testing), so an element covered by another one does not get the clicks. As in Playwright, each action first waits until the element is actionable (attached, visible, stable, enabled, editable, not covered, depending on the action), then waits until the page is idle.
public sealed class PageInputProperties
| Name | Description |
|---|---|
| Raw | Gets the user input of WebPlatform, to send low-level input. Call TestPage.WaitForIdleAsync afterwards. |
Raw
PageInput.csGets the user input of WebPlatform, to send low-level input. Call TestPage.WaitForIdleAsync afterwards.
public UserInput Raw { get; }Property value
Methods
| Name | Description |
|---|---|
| CheckAsync(Element, CancellationToken) | Checks a check box or a radio button with a click, when it is not checked. |
| ClearAsync(Element, CancellationToken) | Clears the value of a text field, then leaves the field. |
| ClickAsync(Element, ClickOptions?, CancellationToken) | Clicks an element at its center (or at ClickOptions.Position), once it is visible, stable, enabled and not covered by another element. |
| ClickAsync(double, double, ClickOptions?, CancellationToken) | Clicks a position of the viewport, in CSS pixels. |
| DoubleClickAsync(Element, CancellationToken) | Double-clicks an element. |
| DragAndDropAsync(Element, Element, CancellationToken) | Drags an element with the mouse, and drops it on another element (the HTML drag and drop events). |
| FillAsync(Element, string, CancellationToken) | Replaces the value of a text field with a text typed with the keyboard, then leaves the field (the change event, so @bind updates the value). Waits until the field is visible, enabled and editable. An element of a label fills the control of the label. |
| FocusAsync(Element, CancellationToken) | Focuses an element. |
| HoverAsync(Element, CancellationToken) | Moves the mouse over an element, once it is visible, stable and not covered by another element. |
| PressAsync(string, string[]) | Presses a key while modifier keys are held (PressAsync("a", "Control")). |
| PressAsync(string, CancellationToken) | Presses and releases a key in the focused element (a character or a key name such as Enter, Tab, ArrowDown). |
| RightClickAsync(Element, CancellationToken) | Clicks an element with the secondary button (the contextmenu event). |
| SelectOptionAsync(Element, string[]) | Selects options of a select element by value or by label, and fires the input and change events. Waits until the element is visible and enabled, and until it has all the options. |
| SwipeAsync(Element, double, double, int, CancellationToken) | Swipes from the center of an element with a finger: a moving touch scrolls the page and fires the touch events. |
| TapAsync(Element, CancellationToken) | Taps an element with a finger (pointer, touch and mouse compatibility events, then click). |
| TypeAsync(Element, string, CancellationToken) | Focuses an element, and types a text with the keyboard (the text is appended to the value of a field). |
| TypeAsync(string, CancellationToken) | Types a text with the keyboard in the focused element. |
| UncheckAsync(Element, CancellationToken) | Unchecks a check box with a click, when it is checked. |
| WheelAsync(Element, double, double, CancellationToken) | Turns the mouse wheel over an element. |
CheckAsync(Element, CancellationToken)
PageInput.csChecks a check box or a radio button with a click, when it is not checked.
public Task CheckAsync(Element element, CancellationToken cancellationToken = default)Parameters
elementElement- The element.
cancellationTokenCancellationToken- A token to cancel the wait.
Returns
Task A task completed once the page is idle.
Exceptions
ElementNotInteractableException- The element is not a check box or a radio button, or the click does not check it.
ClearAsync(Element, CancellationToken)
PageInput.csClears the value of a text field, then leaves the field.
public Task ClearAsync(Element element, CancellationToken cancellationToken = default)Parameters
elementElement- The text field.
cancellationTokenCancellationToken- A token to cancel the wait.
Returns
Task A task completed once the page is idle.
ClickAsync overloads
ClickAsync(Element, ClickOptions?, CancellationToken)
PageInput.csClicks an element at its center (or at ClickOptions.Position), once it is visible, stable, enabled and not covered by another element.
public Task ClickAsync(Element element, ClickOptions? options = null, CancellationToken cancellationToken = default)Parameters
elementElement- The element.
optionsClickOptions?- The options, or null for the default options.
cancellationTokenCancellationToken- A token to cancel the wait.
Returns
Task A task completed once the page is idle.
ClickAsync(double, double, ClickOptions?, CancellationToken)
PageInput.csClicks a position of the viewport, in CSS pixels.
public Task ClickAsync(double x, double y, ClickOptions? options = null, CancellationToken cancellationToken = default)Parameters
xdouble- The horizontal position.
ydouble- The vertical position.
optionsClickOptions?- The options, or null for the default options.
cancellationTokenCancellationToken- A token to cancel the wait.
Returns
Task A task completed once the page is idle.
DoubleClickAsync(Element, CancellationToken)
PageInput.csDouble-clicks an element.
public Task DoubleClickAsync(Element element, CancellationToken cancellationToken = default)Parameters
elementElement- The element.
cancellationTokenCancellationToken- A token to cancel the wait.
Returns
Task A task completed once the page is idle.
DragAndDropAsync(Element, Element, CancellationToken)
PageInput.csDrags an element with the mouse, and drops it on another element (the HTML drag and drop events).
public Task DragAndDropAsync(Element source, Element target, CancellationToken cancellationToken = default)Parameters
sourceElement- The dragged element.
targetElement- The element where the source is dropped.
cancellationTokenCancellationToken- A token to cancel the wait.
Returns
Task A task completed once the page is idle.
FillAsync(Element, string, CancellationToken)
PageInput.csReplaces the value of a text field with a text typed with the keyboard, then leaves the field (the change event, so @bind updates the value). Waits until the field is visible, enabled and editable. An element of a label fills the control of the label.
public Task FillAsync(Element element, string text, CancellationToken cancellationToken = default)Parameters
elementElement- The text field (
input,textareaorcontenteditableelement). textstring- The text.
cancellationTokenCancellationToken- A token to cancel the wait.
Returns
Task A task completed once the page is idle.
Exceptions
ElementNotInteractableException- The element is not a text field.
FocusAsync(Element, CancellationToken)
PageInput.csFocuses an element.
public Task FocusAsync(Element element, CancellationToken cancellationToken = default)Parameters
elementElement- The element.
cancellationTokenCancellationToken- A token to cancel the wait.
Returns
Task A task completed once the page is idle.
HoverAsync(Element, CancellationToken)
PageInput.csMoves the mouse over an element, once it is visible, stable and not covered by another element.
public Task HoverAsync(Element element, CancellationToken cancellationToken = default)Parameters
elementElement- The element.
cancellationTokenCancellationToken- A token to cancel the wait.
Returns
Task A task completed once the page is idle.
PressAsync overloads
PressAsync(string, string[])
PageInput.csPressAsync(string, CancellationToken)
PageInput.csPresses and releases a key in the focused element (a character or a key name such as Enter, Tab, ArrowDown).
public Task PressAsync(string key, CancellationToken cancellationToken = default)Parameters
keystring- The key.
cancellationTokenCancellationToken- A token to cancel the wait.
Returns
Task A task completed once the page is idle.
RightClickAsync(Element, CancellationToken)
PageInput.csClicks an element with the secondary button (the contextmenu event).
public Task RightClickAsync(Element element, CancellationToken cancellationToken = default)Parameters
elementElement- The element.
cancellationTokenCancellationToken- A token to cancel the wait.
Returns
Task A task completed once the page is idle.
SelectOptionAsync(Element, string[])
PageInput.csSelects options of a select element by value or by label, and fires the input and change events. Waits until the element is visible and enabled, and until it has all the options.
SwipeAsync(Element, double, double, int, CancellationToken)
PageInput.csSwipes from the center of an element with a finger: a moving touch scrolls the page and fires the touch events.
net10.0
public Task SwipeAsync(Element element, double deltaX, double deltaY, int steps = 10, CancellationToken cancellationToken = default)net11.0
public Task SwipeAsync(Element element, double deltaX, double deltaY, int steps = 10, CancellationToken cancellationToken = default)Parameters
elementElement- The element where the swipe starts.
deltaXdouble- The horizontal distance, in CSS pixels.
deltaYdouble- The vertical distance, in CSS pixels.
stepsint- The number of moves.
cancellationTokenCancellationToken- A token to cancel the wait.
Returns
Task A task completed once the page is idle.
TapAsync(Element, CancellationToken)
PageInput.csTaps an element with a finger (pointer, touch and mouse compatibility events, then click).
public Task TapAsync(Element element, CancellationToken cancellationToken = default)Parameters
elementElement- The element.
cancellationTokenCancellationToken- A token to cancel the wait.
Returns
Task A task completed once the page is idle.
TypeAsync overloads
TypeAsync(Element, string, CancellationToken)
PageInput.csFocuses an element, and types a text with the keyboard (the text is appended to the value of a field).
public Task TypeAsync(Element element, string text, CancellationToken cancellationToken = default)Parameters
elementElement- The element.
textstring- The text.
cancellationTokenCancellationToken- A token to cancel the wait.
Returns
Task A task completed once the page is idle.
TypeAsync(string, CancellationToken)
PageInput.csTypes a text with the keyboard in the focused element.
public Task TypeAsync(string text, CancellationToken cancellationToken = default)Parameters
textstring- The text.
cancellationTokenCancellationToken- A token to cancel the wait.
Returns
Task A task completed once the page is idle.
UncheckAsync(Element, CancellationToken)
PageInput.csUnchecks a check box with a click, when it is checked.
public Task UncheckAsync(Element element, CancellationToken cancellationToken = default)Parameters
elementElement- The element.
cancellationTokenCancellationToken- A token to cancel the wait.
Returns
Task A task completed once the page is idle.
Exceptions
ElementNotInteractableException- The element is not a check box, or the click does not uncheck it.
WheelAsync(Element, double, double, CancellationToken)
PageInput.csTurns the mouse wheel over an element.
net10.0
public Task WheelAsync(Element element, double deltaX, double deltaY, CancellationToken cancellationToken = default)net11.0
public Task WheelAsync(Element element, double deltaX, double deltaY, CancellationToken cancellationToken = default)Parameters
elementElement- The element.
deltaXdouble- The horizontal delta, in CSS pixels.
deltaYdouble- The vertical delta, in CSS pixels.
cancellationTokenCancellationToken- A token to cancel the wait.
Returns
Task A task completed once the page is idle.