Skip to main content

sdk.automation.setvaluebyxpath

Home > @matterway/sdk > Automation > setValueByXPath

Automation.setValueByXPath() function

Changes the value of a form element by XPath.

Signature:

export declare function setValueByXPath(ctx: Context, selector: string, value: any): Promise<void>;

Parameters

ParameterTypeDescription
ctxContextContext object.
selectorstringElement Xpath selector.
valueanyNew value.

Returns:

Promise<void>

Remarks

Keep in mind that using the helper "setValueByXPath" on form fields will not trigger change events, and the website will not see the change. In this case, one almost always want to use "fillByXPath" or "typeByXPath" instead.

Example

await setValueByXPath(ctx, '//input[@id="id-number"]', '23d79d99S');