October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsPC HealthRecommendedCrashes, freezes, slowdowns? Check your PC nowSpot repairable issues before they interrupt work.Check PCOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk5 min

Puppeteer Screenshot of a Page With an iframe: Capture Embedded Content

Use Puppeteer’s page screenshot for the rendered page, frame APIs for iframe DOM access, or an element screenshot for the iframe region. Learn how to wait for embedded content and diagnose common failures.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

To capture embedded content in Puppeteer, wait for the iframe’s content to be ready, then call page.screenshot() to capture the rendered page. Use Puppeteer’s frame APIs when you need to inspect or interact with the iframe’s DOM; use an element screenshot when you only need the iframe region.

Capture the page after the iframe is ready

Puppeteer’s documented page-level method is Page.screenshot(). Its screenshot guide shows navigating to a page and then taking a screenshot. The guide and API reference identify Puppeteer version 25.12.0 at the time documented; check the current documentation if you use a different version.

As an Amazon Associate I earn from qualifying purchases.

Here is a runnable Node.js example. Install Puppeteer in your project with npm install puppeteer, replace the URL and readiness selector with values for the page you are capturing, then run the script.

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

(async () => {
  const browser = await puppeteer.launch();
  try {
    const page = await browser.newPage();
    await page.goto('https://example.com/page-with-iframe', {
      waitUntil: 'networkidle2',
    });

    const iframeHandle = await page.waitForSelector('iframe');
    if (!iframeHandle) throw new Error('iframe element was not found');

    const frame = await iframeHandle.contentFrame();
    if (!frame) throw new Error('iframe did not produce a frame');

    // Replace this with a meaningful selector from the embedded application.
    await frame.waitForSelector('body');

    await page.screenshot({ path: 'page-with-iframe.png', fullPage: true });
  } finally {
    await browser.close();
  }
})();

networkidle2 is a useful navigation-wait example, not proof that every iframe has finished rendering. An embed may load asynchronously or render its meaningful content after its body exists. Prefer a stable, target-specific selector or application-ready signal inside the frame when one is available. A generic body selector only confirms that a body is present, not that the visual content is ready.

#1 Best Overall
Philips 24 Inch Computer Monitor FHD 100Hz VA VESA Flicker-Free, 241V8LB | 1920×1080 LED Monitor, 4ms GtG, Adaptive Sync, HDMI 1.4, Tilt Adjust, Low Blue Light, 4yr Advance Replacement Warranty
  • CRISP CLARITY: This 23.8″ Philips V line monitor delivers crisp Full HD 1920x1080 visuals. Enjoy movies, shows and videos with remarkable detail
  • INCREDIBLE CONTRAST: The VA panel produces brighter whites and deeper blacks. You get true-to-life images and more gradients with 16.7 million colors
  • THE PERFECT VIEW: The 178/178 degree extra wide viewing angle prevents the shifting of colors when viewed from an offset angle, so you always get consistent colors
  • WORK SEAMLESSLY: This sleek monitor is virtually bezel-free on three sides, so the screen looks even bigger for the viewer. This minimalistic design also allows for seamless multi-monitor setups that enhance your workflow and boost productivity
  • A BETTER READING EXPERIENCE: For busy office workers, EasyRead mode provides a more paper-like experience for when viewing lengthy documents

Puppeteer models each iframe as a Frame. You can also inspect the tree from the main document with page.mainFrame() and a frame’s child frames. See the Puppeteer screenshot guide, Frame API reference, and Page.screenshot() API reference.

Choose the capture boundary you need

Capture the whole rendered page

Use page.screenshot() when the output should show the page as a visitor sees it, including the iframe’s visible area. The screenshot is of the page, not a separate extraction of the iframe’s DOM.

Rank #2
Philips 22 Inch Computer Monitor FHD 100Hz VA VESA Flicker-Free, 221V8LB | 1920×1080 LED Monitor, 4ms GtG, Adaptive Sync, HDMI 1.4, Tilt Adjust, Low Blue Light, 4yr Advance Replacement Warranty
  • CRISP CLARITY: This 22 inch class (21.5″ viewable) Philips V line monitor delivers crisp Full HD 1920x1080 visuals. Enjoy movies, shows and videos with remarkable detail
  • 100HZ FAST REFRESH RATE: 100Hz brings your favorite movies and video games to life. Stream, binge, and play effortlessly
  • SMOOTH ACTION WITH ADAPTIVE-SYNC: Adaptive-Sync technology ensures fluid action sequences and rapid response time. Every frame will be rendered smoothly with crystal clarity and without stutter
  • INCREDIBLE CONTRAST: The VA panel produces brighter whites and deeper blacks. You get true-to-life images and more gradients with 16.7 million colors
  • THE PERFECT VIEW: The 178/178 degree extra wide viewing angle prevents the shifting of colors when viewed from an offset angle, so you always get consistent colors

Capture only the iframe element

If you only need the iframe’s on-page rectangle, take a screenshot of its element handle after it is present and visible:

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.
const iframeHandle = await page.waitForSelector('iframe');
if (!iframeHandle) throw new Error('iframe element was not found');
await iframeHandle.screenshot({ path: 'iframe-region.png' });

The Puppeteer screenshot guide documents ElementHandle.screenshot(); it attempts to scroll a hidden element into view. This captures the iframe element’s region, which is a different boundary from a whole-page screenshot.

Rank #3
Sale
Dell 24 Monitor - SE2426H - 23.8-inch FHD (1920x1080) 144Hz 1ms Display, in-Plane Switching (IPS) Technology, AMD FreeSync™, TÜV 3-Star 2X HDMI, Tilt
  • Clear visuals. Fluid motion: A 144Hz refresh rate and 1ms MPRT deliver smooth, tear‑free motion across work, gaming, and streaming for clearer, more fluid viewing.
  • Eye comfort: TÜV Rheinland 3‑star* certification reduces harmful blue light while preserving stunning color quality without compromise. *TÜV Rheinland 3-star eye comfort certification.
  • Wide viewing angle: Get consistent views across a wide 178° /178° viewing angle.
  • In-Plane Switching (IPS): See excellent color accuracy and consistency across wide viewing angles with In-plane Switching (IPS) technology.
  • Ultra-thin bezels: Maximize your viewing experience with thin bezels.

Inspect or interact with iframe content

Resolve the iframe’s content frame with contentFrame(), then use frame methods to query or interact with its document. Frame access is for DOM work; it is not a substitute for choosing the screenshot boundary. Puppeteer’s Frame API describes frames and access to the page’s frame tree.

Handle timing and embed-specific behavior

  • Wait for something meaningful: A frame can exist before its app is visually ready. Wait for a selector or readiness signal specific to the embed, and take the screenshot only after that condition succeeds.
  • Keep navigation waits in perspective: networkidle2 can help with navigation but is not a universal iframe-ready guarantee. Some embeds continue work after the main page’s navigation event.
  • Validate the actual target: The result can depend on the page, browser environment, authentication state, and site restrictions. Puppeteer’s cited documentation does not establish a universal workaround or behavior for every cross-origin embed.
  • Use the least complicated method that fits: If you only need a visual image, screenshot the rendered page or iframe element. Reach into the frame DOM only when you need to locate, inspect, or interact with content.

Troubleshoot common iframe screenshot failures

Symptom Likely cause What to try
The screenshot omits the embedded content or shows a placeholder. The iframe had not reached its meaningful ready state when capture ran. Wait for a target-specific selector or application signal inside the frame before calling page.screenshot().
waitForSelector('iframe') times out. The page did not add an iframe matching that selector, or the iframe appears later. Check the selector against the page, and wait for the condition that actually creates the iframe.
contentFrame() returns null. The element handle did not yield a frame at that point. Confirm that the selected element is the iframe and retry only after it is present; treat a missing frame as an error rather than proceeding as if its DOM were available.
The frame loads, but the expected selector never appears. The selector may not match the embed, or the content may depend on page state, authentication, or site-specific behavior. Inspect the target frame tree and verify the selector and required state on the actual page. Do not assume a general cross-origin bypass.
An element screenshot does not show the full embedded document. An element screenshot targets the iframe’s on-page element region, not necessarily every part of a long document inside it. Use a page screenshot for the visible page composition; choose and validate the capture boundary against the output you need.

Or skip the browser setup

ScreenshotNeo is a screenshot API and MCP server. A GET request with a URL returns an image or PDF; for a URL-only capture, use the API call below. See the ScreenshotNeo API documentation for request options.

Rank #4
Sale
Samsung 27" Essential S3 (S36GD) Series FHD 1800R Curved Computer Monitor | 100Hz, Game Mode, Advanced Eye Comfort, HDMI and D-sub Ports (LS27D366GANXZA)
  • CURVED FOR ENHANCED ENGAGEMENT: An immersive viewing experience with a curved monitor that wraps more closely around your field of vision; It creates a wider view, enhancing depth perception and minimizing peripheral distraction
  • SMOOTH PERFORMANCE FOR SEAMLESS CONTENT: Stay in the action when playing games, watching videos, or working on creative projects; The 100Hz refresh rate reduces lag and motion blur so you don't miss a thing in fast-paced moments¹
  • MORE GAMING POWER: Gain the edge with optimizable game settings; Color and image contrast can be adjusted to see scenes more vividly and spot enemies hiding in the dark; Game Mode adjusts any game to fill the screen so you can view every detail²
  • KEEP IT EASY ON THE EYES: Care for your eyes and stay comfortable, even during long sessions; Advanced eye comfort technology certified by TÜV reduces eye strain by minimizing blue light and reducing irritating screen flicker²
  • INCREASED VERSATILITY: Connect to more; Plug devices straight into your monitor for increased flexibility, making your computing environment even more convenient
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://example.com/page-with-iframe -o shot.webp

ScreenshotNeo accepts cookie and consent banners and removes more than 60 known consent platforms, newsletter popups, and chat widgets before capture; each cleanup step can be turned off. Bot checks and CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed, and response headers report the page verdict and billing status. Its MCP server provides take_screenshot, get_page_info, and capture_pdf for AI agents and MCP clients. The free plan includes 1,000 shots a month with no card; paid plans start at $5 for 3,000 shots.

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

Sign up for ScreenshotNeo’s free plan to get 1,000 screenshots a month with no card.

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

Frequently Asked Questions

Does Puppeteer need frame access to screenshot an iframe?

No. For a visual capture, screenshot the rendered page with page.screenshot(). Use frame access when you need to inspect or interact with the iframe’s DOM.

Best Value
Sale
Sceptre New 22-Inch Gaming Monitor, FHD 1080p, Up to 144Hz, HDMI, DisplayPort, Built-in Speakers, Machine Black (E225W-FW144 Series, 2026)
  • 【INTEGRATED SPEAKERS】Whether you're at work or in the midst of an intense gaming session, our built-in speakers provide rich and seamless audio, all while keeping your desk clutter-free.
  • 【EASY ON THE EYES】 Protect your eyes and enhance your comfort with Blue-Light Shift technology. This feature reduces harmful blue light emissions from your screen, helping to alleviate eye strain during long hours of use and promoting healthier viewing habits.
  • 【WIDEN YOUR PERSPECTIVE】Our sleek minimal bezel design ensures undivided attention. The nearly bezel-free display seamlessly connects in a dual monitor arrangement, delivering an unobstructed view that lets you focus on more at once, completely distraction-free.

Does networkidle2 guarantee the iframe is ready?

No. Treat it as a navigation wait condition, then wait for a meaningful, target-specific signal from the embed.

Can Puppeteer capture every cross-origin iframe?

The cited Puppeteer documentation does not establish a universal result for every cross-origin embed. Validate the target site, browser, and authentication state you use.

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

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 *

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
Outdated Drivers Are Slowing You DownFree scan - exact matches
PC Slower Than It Used to Be?Free scan - under a minute

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.