DriversRecommendedOutdated drivers can make a good PC feel brokenScan driver issues before chasing fixes manually.Scan NowOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsSlow PC?RecommendedPC slow today? Run a repair scan before it gets worseResolve common Windows issues and optimize system performance.Scan Now×
Skip to content
World desk3 min

How to Get the Page from a Puppeteer Frame

Puppeteer's frame.page() returns the Page that owns a frame. Learn when page-level methods are appropriate and how to keep iframe work scoped to its Frame.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Call frame.page() to get the Puppeteer Page that owns a frame:

const page = frame.page();

The call is synchronous. It returns the owning page; it does not turn an iframe into a separate tab. If your task is to read or interact with content inside that iframe, keep using the Frame object.

As an Amazon Associate I earn from qualifying purchases.

What frame.page() returns

Puppeteer’s documented signature is page(): Page. The returned object is “The page associated with the frame.” See the Frame.page() API reference.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
const page = frame.page();

// `page` is the Page that contains `frame`.
// No `await` is needed for frame.page().

A Page represents a browser tab (or an extension background page); a Frame represents a document frame such as an <iframe>. A page can contain a main frame and nested child frames. Getting the page from a frame identifies its owner, but does not make the iframe independently navigable as a tab.

Choose Page or Frame for the operation

Need Use Execution scope
Page-level controls or the page that owns a frame frame.page(), then the relevant Page method The owning browser page
Evaluate JavaScript or query elements inside a particular iframe frame.evaluate(), frame.$eval(), frame.waitForSelector(), or another Frame method That frame’s document context
Query the main document page.$(selector) or another page selector shortcut The page’s main frame

Puppeteer documents Frame.evaluate() as behaving like Page.evaluate(), except that it runs in the selected frame’s context. By contrast, page.$(selector) is a shortcut for page.mainFrame().$(selector); it does not search every child frame. See the Frame API reference and Page API reference.

Find the frame before getting its page

If you already hold the Frame, call frame.page() directly. To locate a frame from a page, inspect all frames with page.frames() or traverse from page.mainFrame() using childFrames().

const frames = page.frames();

for (const frame of frames) {
  console.log(frame.url());
  // Use frame.evaluate(...) or other Frame methods for this frame's content.
}

You can also traverse the frame tree:

function visit(frame) {
  console.log(frame.url());
  for (const child of frame.childFrames()) {
    visit(child);
  }
}

visit(page.mainFrame());

When a frame will appear later, the Page API includes waitForFrame() for waiting until a matching frame is available. Check the current Page API reference for its signature and matcher options for your installed Puppeteer version.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Identify a frame using its current element attributes

The Frame reference marks frame.name() deprecated: its value is captured when the frame is created and may not reflect later changes to the DOM name attribute. For the current name or ID, read the frame element instead:

for (const frame of page.frames()) {
  const element = await frame.frameElement();
  const attributes = await element.evaluate(el => ({
    name: el.getAttribute('name'),
    id: el.id,
  }));

  console.log(frame.url(), attributes);
}

Use frame.page() after selecting the frame if you need its owning page; use Frame methods for work within its document. The relevant details are in Puppeteer’s Frame API reference.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Or skip the browser setup

If the actual goal is a screenshot rather than DOM-level iframe interaction, ScreenshotNeo offers a website screenshot API and MCP server. One GET request can return an image or PDF. The API handles cookie banners, popups and chat widgets before the shot; bot checks, blank pages and failed loads are never billed. Its MCP server lets AI agents take screenshots, and 1,000 screenshots a month are free with no card; paid plans start at $5 for 3,000.

For example, this cURL request captures a page as WebP:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp

See the ScreenshotNeo API documentation for options and response details. Sign up for 1,000 free screenshots a month with no card.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Windows Errors? Fix Them Before They SpreadFree repair scan
Outdated Drivers Are Slowing You DownFree scan - exact matches

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.