Skip to Content
Browser UtilswaitForElement

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

ParamTypeDefaultDescription
selectorstring—CSS selector or XPath
timeoutnumber8000Max wait time (ms)
scopeFrame—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); // → null

Error Handling

Soft fail — returns null if element not found within timeout. Does not throw.

Last updated on