Page.waitForFrame() method

Waits for a frame matching the given conditions to appear.

Signature

class Page {
  waitForFrame(
    urlOrPredicate: string | ((frame: Frame) => Awaitable<boolean>),
    options?: WaitTimeoutOptions,
  ): Promise<Frame>;
}

Parameters

Parameter Type Description
urlOrPredicate string \| ((frame: [Frame](./puppeteer.frame.md)) => [Awaitable](./puppeteer.awaitable.md)<boolean>)
options [WaitTimeoutOptions](./puppeteer.waittimeoutoptions.md) _(Optional)_

Returns:

Promise<Frame>

Example

const frame = await page.waitForFrame(async frame => {
  const frameElement = await frame.frameElement();
  if (!frameElement) {
    return false;
  }
  const name = await frameElement.evaluate(el => el.getAttribute('name'));
  return name === 'test';
});