Appearance
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
| Parameter | Type | Description |
|---|---|---|
ctx | Context | Context object. |
label | string | Text to wait for. |
element? | string | Element tag to search inside. |
options? | WaitForSelectorOptions | Wait 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 });