NaiboWang/EasySpider · error · Error

No iframes found in the current page while searching for ${v

Error message

No iframes found in the current page while searching for ${value}

What it means

Thrown by findElement in ElectronJS/main.js:229 when the caller passes iframe=true but the current top-level document contains zero <iframe> elements. It is a guard that aborts before attempting the recursive search, since there is nothing to recurse into.

Source

Thrown at ElectronJS/main.js:229

                    console.error(`Exception while processing frame: ${error}`);
                }
            }
        } catch (error) {
            console.error(`Exception while processing frame: ${error}`);
        }
    }

    throw new Error(`Element ${value} not found in any frame or iframe`);
}

async function findElement(driver, by, value, iframe = false) {
    // Switch back to the main document
    await driver.switchTo().defaultContent();

    if (iframe) {
        const frames = await driver.findElements(By.tagName("iframe"));
        if (frames.length === 0) {
            throw new Error(
                `No iframes found in the current page while searching for ${value}`
            );
        }
        const element = await findElementRecursive(driver, by, value, frames);
        return element;
    } else {
        // Find element in the main document as normal
        let element = await driver.findElement(by(value));
        return element;
    }
}

async function findElementAcrossAllWindows(
    msg,
    notifyBrowser = true,
    scrollIntoView = true
) {
    let handles = await driver.getAllWindowHandles();

View on GitHub (pinned to 191bd6d754)

Solutions

  1. Check whether the target page actually contains an <iframe> (DevTools: document.querySelectorAll('iframe').length).
  2. Wait for the page/iframe to render before searching (driver.wait until iframe located, or check document.readyState).
  3. If the element is in the main document, call findElement without iframe=true (or set iframe=false).
  4. If the iframe is in a shadow DOM, switch to a JS-based location strategy instead of tag-name enumeration.

Example fix

// before
let element = await findElement(driver, By.xpath, xpath, true);

// after - only use iframe mode when iframes exist
const frames = await driver.findElements(By.tagName('iframe'));
let element = frames.length
  ? await findElement(driver, By.xpath, xpath, true)
  : await driver.findElement(By.xpath(xpath));
Defensive patterns

Strategy: validation

Validate before calling

const frames = await driver.findElements(By.tagName('iframe'));
if (iframe && frames.length === 0) {
  // skip the call that would throw
}

Prevention

When it happens

Trigger: findElement(driver, by, value, iframe=true) runs driver.findElements(By.tagName('iframe')); if the returned array is empty it throws this Error immediately.

Common situations: The page navigated to a URL that has no iframes; the iframe flag was set erroneously for a top-document element; the page has not finished loading so iframes are not yet in the DOM; or the iframe lives inside a shadow root that By.tagName cannot reach.

Related errors


AI-assisted analysis of NaiboWang/EasySpider@191bd6d754 (2026-08-13). Data as JSON: /api/errors/97ad3488f6aed059. Report an issue: GitHub.