Skip to main content

sdk.automation.getelementbytext

Home > @matterway/sdk > Automation > getElementByText

Automation.getElementByText() function

Returns an element based on its text content.

Signature:

export declare function getElementByText(ctx: Context, text: string, options?: FilterOptions): Promise<import("puppeteer-core").ElementHandle<Node>>;

Parameters

ParameterTypeDescription
ctxContextContext object.
textstringText to search for.
optionsFilterOptions(Optional) Options for filtering.

Returns:

Promise<import("puppeteer-core").ElementHandle<Node>>

The selescted element as an element handle.

Example 1

const $el = await getElementByText(ctx, 'Save and Submit');

Example 2

const $el = await getElementByText(ctx, 'Last Name', {filterElementWithTag: 'div'});