waitForElement
Wait for an element to appear and become visible. Returns null if not found (soft fail).
Signature
const el = await utils.waitForElement(selector, timeout?, scope?)Parameters
| Param | Type | Default | Description |
|---|---|---|---|
selector | string | — | CSS selector or XPath |
timeout | number | 8000 | Max wait time (ms) |
scope | Frame | — | Optional frame to search within |
Examples
const el = await utils.waitForElement("#my-btn");
if (el) await el.click();
// Custom timeout
const el2 = await utils.waitForElement(".spinner", 3000);
// Returns null on timeout
const el3 = await utils.waitForElement("#nonexistent", 1000); // → nullError Handling
Soft fail — returns null if element not found within timeout. Does not throw.
Last updated on