Skip to main content

sdk.automation.typebyxpath

Home > @matterway/sdk > Automation > typeByXPath

Automation.typeByXPath() function

Types into a form field by Xpath, after the existing text.

Signature:

export declare function typeByXPath(ctx: Context, selector: string, value: string, options?: FillOptions): Promise<void>;

Parameters

ParameterTypeDescription
ctxContextContext object.
selectorstringXpath selector.
valuestringA text to type into field.
optionsFillOptions(Optional)

Returns:

Promise<void>

Remarks

Triggers an event for each character. If you want to clear the field first, use the helper "fillByXPath".

Example 1

await typeByXPath(ctx, '//input[@id="message"]', 'Hello');

Example 2

await typeByXPath(ctx, '//input[@id="message"]', 'Hello', {
delay: 500,
clear: true,
blur: true,
});