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
Parameter | Type | Description |
---|---|---|
ctx | Context | Context object. |
text | string | Text to search for. |
options | FilterOptions | (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'});