Skip to content

Function: waitForText()

ts
function waitForText(
   ctx: Context, 
   label: string, 
   element?: string, 
options?: WaitForSelectorOptions): Promise<ElementHandle<Element> | null>;

Defined in: src/wait/waiters/waitForText.ts:38

Wait for text to appear inside an element.

Parameters

ParameterTypeDescription
ctxContextContext object.
labelstringText to wait for.
element?stringElement tag to search inside.
options?WaitForSelectorOptionsWait options.

Returns

Promise<ElementHandle<Element> | null>

The matched element handle.

Examples

ts
// Wait for the "Order Confirmed" heading to show up
await waitForText(ctx, 'Order Confirmed', 'h1');
ts
// Wait for a toast message to disappear
await waitForText(ctx, 'Saved!', 'span', { hidden: true, timeout: 3000 });

Matterway Assistant SDK Documentation