waitForElementHidden
Wait for an element to disappear from the DOM or become hidden. This is the inverse of waitForElement().
Added in v1.0.19
const gone = await utils.waitForElementHidden(selector, timeout?, scope?)| Param | Type | Default | Description |
|---|---|---|---|
selector | string | — | CSS selector or XPath expression |
timeout | number | 8000 | Max wait time in ms. 0 = instant check |
scope | Frame? | — | Optional Frame to search within |
Returns boolean — true if element disappeared, false if still visible after timeout (soft fail — does NOT throw).
Example 1 — Wait for loading spinner to disappear
await utils.click("#submit");
await utils.waitForElementHidden("//div[@class='loading-spinner']", 10000);
// spinner is gone, safe to proceedExample 2 — Instant check if element is hidden
const isHidden = await utils.waitForElementHidden("#modal", 0);
if (isHidden) {
utils.logger.info("Modal already closed");
}Example 3 — Wait for toast notification to fade
await utils.waitForElementHidden(".toast-notification", 5000);
utils.logger.success("Toast dismissed");Last updated on