October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsClean PCRecommendedOne scan can reveal what keeps slowing WindowsLook for cleanup and repair opportunities.Run ScanOctober 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

How to Screenshot Pages After Network Idle in a Batch with Playwright

A practical Playwright pattern for batch screenshots, with network-idle caveats, application-specific waits, consistent output, and troubleshooting.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Use Playwright’s page.goto(url, { waitUntil: 'networkidle' }) for each URL, then save the screenshot to a unique file. For a batch, reuse a browser context and create a page per URL; keep parallel work bounded. Network idle means no network connections for at least 500 ms, but it is not proof that the content you care about is ready. If a specific element or application state matters, wait for that condition instead.

Capture a batch of pages after network idle

This runnable Node.js example uses Playwright’s Chromium browser, one shared context, and a serial loop. It creates the output directory, writes a full-page PNG for each URL, and closes each page before moving on.

As an Amazon Associate I earn from qualifying purchases.

const { chromium } = require('playwright');
const fs = require('node:fs/promises');

(async () => {
  const browser = await chromium.launch();
  const context = await browser.newContext();
  const urls = [
    'https://example.com/',
    'https://playwright.dev/',
  ];

  await fs.mkdir('screenshots', { recursive: true });

  try {
    for (const [index, url] of urls.entries()) {
      const page = await context.newPage();
      try {
        await page.goto(url, { waitUntil: 'networkidle' });
        await page.screenshot({
          path: `screenshots/page-${index + 1}.png`,
          fullPage: true,
        });
      } finally {
        await page.close();
      }
    }
  } finally {
    await browser.close();
  }
})();

Save it as batch-screenshots.js, install Playwright with npm install playwright, install its browser with npx playwright install chromium, then run node batch-screenshots.js. The output files are screenshots/page-1.png and screenshots/page-2.png. Sequential capture is slower than parallel capture, but is a predictable starting point and avoids opening an unbounded number of pages.

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

Use an application-specific readiness condition when it matters

The Page API defines networkidle as no network connections for at least 500 ms and explicitly discourages it as a testing readiness signal. A page can keep making requests, so navigation may never reach that state; conversely, a quiet network does not prove a particular image, lazy-loaded section, animation, or application state is ready. For a meaningful condition, use a locator wait or assertion, for example:

#1 Best Overall
await page.goto(url, { waitUntil: 'domcontentloaded' });
await page.locator('[data-testid="report-ready"]').waitFor({ state: 'visible' });
await page.screenshot({ path: outputPath, fullPage: true });

Replace the selector with an element that reliably signals the content you need. Playwright lists load, domcontentloaded, commit, and networkidle as navigation lifecycle options; choose the earliest useful navigation point, then wait on the actual page condition. See the Playwright Page API.

Wait for network idle after navigation

If you need to separate navigation from the idle wait, navigate first and then wait:

await page.goto(url, { waitUntil: 'commit' });
await page.waitForLoadState('networkidle');
await page.screenshot({ path: outputPath, fullPage: true });

page.waitForLoadState('networkidle') applies to the current document after navigation has committed. If the requested state has already been reached, it resolves immediately. A fixed sleep such as waitForTimeout() is not a reliable substitute: it can waste time on a fast page and still capture an unready one.

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

Organize pages, sessions, and output files

Reuse a context for related URLs

A BrowserContext can contain multiple pages. Use one context when pages should share session and context-level settings such as viewport, routes, or locale; create pages with context.newPage(). Use separate contexts when the pages need session isolation. The appropriate isolation boundary depends on the job. The Playwright Pages guide documents creating and enumerating pages with context.newPage() and context.pages().

Rank #2
Dell Latitude 5420 14" FHD Business Laptop Computer, Intel Quad-Core i5-1145G7, 16GB DDR4 RAM, 256GB SSD, Camera, HDMI, Windows 11 Pro (Renewed)
  • 256 GB SSD of storage.
  • Multitasking is easy with 16GB of RAM
  • Equipped with a blazing fast Core i5 2.00 GHz processor.

Choose a collision-free name for every capture

The example uses the batch index, so repeated hostnames or identical paths cannot overwrite one another within a run. For persistent batches, use a sanitized URL plus an index or a stable hash, and account for duplicate input URLs. Avoid using raw URLs as filenames: query strings and reserved characters are not valid or convenient on every operating system.

Scale up with bounded concurrency

For a large batch, process a limited number of URLs concurrently rather than creating a page for every URL at once. Each active page consumes browser resources, and an unbounded burst can make the machine slow or unreliable. The official documentation does not prescribe a concurrency number; select a limit appropriate to the host and page weight, then adjust based on observed resource use and failures. Keep output names unique even when tasks finish out of order.

Make screenshots comparable

For repeatable captures or visual comparisons, hold rendering conditions steady: browser engine and version, viewport, locale, and the environment that runs the browser. Playwright notes that output can vary with host operating system, browser version, settings, hardware, power source, and headless mode, and recommends using the same environment as the baseline. See its visual comparisons guide.

Free tools Windows power users keep installed

One-click scans. No signup required.

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

If the purpose is a Playwright Test visual regression assertion rather than saving image files, expect(page).toHaveScreenshot() waits for two consecutive screenshots to match before comparing the last image with the expectation. That stabilization is useful for screenshot assertions; it is not required for ordinary page.screenshot() output.

Rank #3
15.6 Inch Win 11 Laptop Computer, N4020, 4GB DDR4 RAM, 128GB Storage | LPDDR4 RAM, 180° Lay-Flat, Dual-Band WiFi, Type-C PD Fast Charging, Thin & Lightweight for Students, Home & Office, Gray
  • WINDOWS 11 | STABLE PERFORMANCE: Powered by Intel Celeron N4020 processor and Windows 11 system, this laptop delivers stable performance for everyday computing tasks. It supports web browsing, online learning, document editing, email communication, and basic office work with optimized power efficiency, providing a practical and reliable experience for essential daily use for daily use.
  • 15.6” FHD IPS DISPLAY: Features a 15.6-inch Full HD IPS display with narrow bezels, offering wider viewing angles and clearer image details compared to standard panels. The improved screen-to-body ratio enhances visual experience for study, reading, document work, and video playback, making it suitable for both productivity and entertainment use.
  • 4GB DDR4 + 128GB eMMC STORAGE: Equipped with 4GB DDR4 memory and 128GB eMMC storage for everyday basics such as browsing, documents, email, and online learning platforms. The built-in TF card slot supports storage expansion up to 1TB, giving you more flexibility for files, photos, videos, and daily documents. TF card not included.
  • CONNECTIVITY & PORTS: Includes 1× TF card slot, 2× USB 3.2 Gen1 ports, and 2× full-featured Type-C ports (USB 3.2 Gen1). The Type-C ports support data transfer, charging, and video output, enabling flexible connection with external devices such as monitors, storage, and peripherals for daily work and study use.
  • LIGHTWEIGHT DESIGN | ONLINE COMMUNICATION: Designed with a slim, portable profile, this laptop is easy to carry for school, commuting, and travel. A built-in 1MP front camera supports online classes, video meetings, remote communication, and everyday conferencing. The 3300mAh battery works with the low-power system design to support practical daily use, while thermal optimization helps maintain quieter operation during extended tasks.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Troubleshoot common batch failures

  • The navigation waits too long or times out: the page may keep network connections open, so it never meets the idle condition. Use an earlier lifecycle point such as domcontentloaded and wait for the specific element you need, or handle the timeout for that URL so one failure does not prevent the rest of the batch.
  • The screenshot is missing content despite network idle: network quiet does not guarantee an image, lazy-loaded region, or application state has rendered. Wait for a relevant locator or state before capture; for long pages, consider whether content only appears after scrolling.
  • Files overwrite each other: duplicate or sanitized URL-derived names may collide. Include the batch index or another unique identifier in every output path.
  • The batch exhausts resources or becomes unstable: reduce parallelism, close each page when its capture finishes, and close the browser in a finally block as in the example.
  • Visual output differs between runs or machines: keep browser version, engine, viewport, locale, and host environment consistent when comparing captures; environmental differences can affect rendering.

Or skip the browser setup

ScreenshotNeo offers a screenshot API and MCP server for developers. One GET request can return an image or PDF; its parameters include waiting for network idle or a selector, full-page capture, CSS-selector element capture, viewport and device settings, and bulk capture of up to 100 URLs per call. Cookie banners are accepted and removed, along with known consent platforms, newsletter popups, and chat widgets, before capture; each step can be turned off. Bot checks, blank pages, timeouts, failed loads, and cache hits are not billed, and the response identifies the page verdict and billing status. Its MCP tools let AI agents take screenshots, get page information, and capture PDFs.

Example cURL request (replace the URL with a target page):

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 authentication and options. The Free plan includes 1,000 shots per month with no card; paid plans start at $5 for 3,000 shots. Sign up for ScreenshotNeo’s free plan.

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

Sources

Frequently Asked Questions

Does network idle mean all page content is ready?

No. It only indicates a period with no network connections; it does not confirm that a particular application state or visual element is ready.

Can I use one Playwright context for every URL in a batch?

Yes, when the pages should share context-level settings and session. Use separate contexts when session isolation is required.

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
PC Slower Than It Used to Be?Free scan - under a minute
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.