Skip to content

Function: findElement()

ts
function findElement(
   ctx: Context, 
   rootSelector: string, 
targetSelector: string): Promise<ElementHandle<Element> | null>;

Defined in: src/pages/index.ts:287

Search for an element inside nested shadow roots.

Parameters

ParameterTypeDescription
ctxContextThe current Context.
rootSelectorstringSelector for the root element to start the search from.
targetSelectorstringSelector for the target element within shadow DOM trees.

Returns

Promise<ElementHandle<Element> | null>

The matching ElementHandle, or null if not found.

Example

ts
// Find an input buried inside a Salesforce Lightning component.
const emailInput = await findElement(ctx, 'lightning-record-form', 'input#email');
await clickOnElementHandle(emailInput);

Matterway Assistant SDK Documentation