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

iTechGuides is reader-supported. When you buy through links on our site, we may earn an affiliate commission. As an Amazon Associate I earn from qualifying purchases. Learn more

Wait for Puppeteer’s navigation promise to resolve with waitUntil: 'networkidle2', then call page.screenshot(). Use 'networkidle0' when you need the stricter threshold of zero active network connections. Neither option guarantees that a particular application has finished rendering; for that, wait for the relevant selector or state explicitly.

Wait for network idle during navigation

For most pages, navigate with waitUntil: 'networkidle2' and take the screenshot after page.goto() resolves. The example below saves a PNG and closes the browser even if navigation or capture fails.

import puppeteer from 'puppeteer';

const browser = await puppeteer.launch();
try {
  const page = await browser.newPage();
  await page.goto('https://example.com', {
    waitUntil: 'networkidle2',
  });
  await page.screenshot({ path: 'page.png' });
} finally {
  await browser.close();
}

The current Puppeteer screenshot guide uses this navigation-and-capture pattern. page.goto() accepts navigation options and resolves with the main-resource response; documented cases such as navigating to about:blank or same-URL hash navigation can yield null. See the Page.goto() API.

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

Choose between networkidle0 and networkidle2

Option Connection threshold When it may fit
networkidle0 No more than zero network connections for at least 500 ms Use when the page can reach a period with no active connections and you want the stricter threshold.
networkidle2 No more than two network connections for at least 500 ms Use when a page may retain a small number of background connections.

These are connection-count conditions over time, not a ranking of speed or reliability. Puppeteer’s lifecycle event definitions document the thresholds and interval; they do not establish that either setting is universally better.

Wait for network idle after navigation

If the page is already open or you want to separate navigation from the idle condition, call page.waitForNetworkIdle() before capturing:

await page.goto('https://example.com');
await page.waitForNetworkIdle();
await page.screenshot({ path: 'page.png' });

The Page.waitForNetworkIdle() API documents concurrency with a default of 0 and idleTime with a default of 500 milliseconds. The method waits at least the configured idle time. This checks network activity; it does not certify that all delayed rendering or application work is finished.

Wait for the content you actually need

When the screenshot must show a specific widget, result, or page state, wait for that condition directly, then capture. For example, a selector wait can follow navigation:

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.
await page.goto('https://example.com', {
  waitUntil: 'networkidle2',
});
await page.waitForSelector('#report-ready');
await page.screenshot({ path: 'report.png' });

Replace #report-ready with a selector that appears when the needed content is present. An application-specific wait is more meaningful than inferring visual readiness from network connections alone.

Choose screenshot output and area

page.screenshot() can save an image to a path or return image data. Its format can be inferred from the file extension; PNG is the default type. A basic viewport screenshot is not full-page by default. Set fullPage: true to capture the full page, or use clip to capture a defined region. See the ScreenshotOptions API.

await page.screenshot({
  path: 'full-page.png',
  fullPage: true,
});

Troubleshoot waits and screenshots

  • The page never seems idle: A page that keeps requests active may not reach the threshold you selected. Try networkidle2 instead of networkidle0, or wait for the specific content selector that defines readiness.
  • The screenshot is missing content despite the idle wait: Network idleness only measures connections during the documented interval. Add an explicit wait for the relevant selector or application condition before capture.
  • Navigation resolves without a response: page.goto() can return null for documented cases such as about:blank or same-URL hash navigation. Do not treat the return value alone as proof that an ordinary network response was received.
  • The image cuts off below the viewport: Set fullPage: true; the default is false.
  • The API behaves differently than expected: The current official docs search results surfaced Puppeteer version 25.12.0. Check the version installed in your project when exact API behavior matters.

Or skip the browser setup

ScreenshotNeo offers a one-request screenshot API. For example, save a screenshot of a URL as WebP:

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://example.com -o shot.webp

See the ScreenshotNeo documentation for request options. ScreenshotNeo removes cookie banners, popups, and chat widgets before capture; bot checks, blank pages, and failed loads are never billed. Its MCP server lets AI agents take screenshots. The free plan includes 1,000 screenshots a month with no card, and paid plans start at $5 for 3,000.

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

Sign up for ScreenshotNeo free.

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

Frequently Asked Questions

Does network idle mean every image and animation has finished?

No. It describes network-connection activity over an interval, not every visual or application-specific condition. Wait for the content or state the screenshot needs.

Can I capture the screenshot as data instead of saving a file?

Yes. Puppeteer’s screenshot method can return image data as a Uint8Array, or as a string when base64 encoding is requested; use the screenshot options documentation for details.

Best Value
The SQL Programming Language: .
  • Used Book in Good Condition

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.