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 desk7 min

Puppeteer: Wait for Infinite Scroll to Finish Before Taking a Screenshot

Puppeteer cannot infer when an infinite feed is finished. Use an app-specific signal when possible, or a bounded scroll-and-stability loop before taking a full-page screenshot.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Puppeteer has no built-in wait that can tell when an infinite-scroll feed is truly finished. Trigger the page’s scrolling behavior, then wait for a page-specific end marker or expected item count. If the site exposes no such signal, use a bounded loop that checks rendered content or scroll height after repeated scrolls. Only then capture with page.screenshot({ fullPage: true }); fullPage captures the current document but does not load more content by itself.

Why network idle and full-page capture are not enough

Puppeteer’s screenshot guide demonstrates navigation with waitUntil: 'networkidle2', and its documentation says to use Page.screenshot() to capture screenshots. That navigation example is not a guarantee that an infinite feed is complete. A page can be quiet between scroll-triggered requests, and a later scroll can still load more content. See the Puppeteer screenshot guide and Page.screenshot() API (documentation version 25.12.0 when accessed).

As an Amazon Associate I earn from qualifying purchases.

fullPage: true controls the capture extent: it captures the full current page. It does not trigger every future scroll-based load. Similarly, Page.waitForNetworkIdle() waits for a quiet network interval, not for a site’s feed logic to declare completion. It can help settle a batch after scrolling, but should not be the sole stopping condition.

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

Choose a completion signal for the page

First determine whether the page scrolls the document, a nested panel, or a “load more” control. Prefer an explicit application signal over a visual heuristic.

#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
Page behavior Preferred completion signal Limitation
Known final result count The rendered item count reaches the expected count. You need the expected count and a selector for the right item nodes.
Explicit end marker A terminal marker appears, or becomes visible. Confirm that the marker means the feed is exhausted.
Items appended to the document Item count and document height remain stable over several scroll cycles. This is a heuristic; delayed content may still appear.
Nested scroll panel Panel position/height and item count indicate no more content. Scrolling the window will not exercise the panel.
“Load more” button Click until the control is disabled, absent, or a terminal marker appears. Distinguish loading and disabled states, and detect failed loads.
Ongoing analytics or polling An app-specific content signal, optionally with a bounded wait. Network idle may never occur, or may occur between content batches.

Wait for an explicit end marker when available

Page.waitForFunction() waits until a function evaluated in the browser context returns a truthy value. If the application renders a marker at the end of its results, wait for that marker before capturing:

await page.waitForFunction(() =>
  document.querySelector('[data-testid="end-of-results"]') !== null
);
await page.screenshot({ path: 'results.png', fullPage: true });

The selector is illustrative, not a Puppeteer-provided element. Replace it with a marker that actually exists on the target site, and set an appropriate timeout so a missing marker cannot leave the script waiting indefinitely. If the marker can exist before the final batch has rendered, combine it with a relevant item-count or loading-state check.

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

Use a bounded scroll loop when there is no explicit signal

For a document-level feed that appends items as the page scrolls, a practical fallback is to scroll to the current bottom, allow the page to react, and compare height and item count over consecutive rounds. The values below are example tuning choices, not universal timing recommendations. This runnable Node.js example requires Puppeteer to be installed in the project:

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

async function loadUntilStable(page, {
  itemSelector,
  stableRounds = 3,
  maxRounds = 30,
  pauseMs = 500,
} = {}) {
  let previousHeight = -1;
  let previousCount = -1;
  let stable = 0;

  for (let round = 0; round < maxRounds && stable < stableRounds; round++) {
    await page.evaluate(() =>
      window.scrollTo(0, document.documentElement.scrollHeight)
    );
    await new Promise(resolve => setTimeout(resolve, pauseMs));

    // Optional settling aid, not proof that the feed is complete.
    try {
      await page.waitForNetworkIdle({ idleTime: 500, timeout: 3000 });
    } catch {
      // Continue to the content checks; some pages never become network-idle.
    }

    const current = await page.evaluate(selector => ({
      height: document.documentElement.scrollHeight,
      count: selector ? document.querySelectorAll(selector).length : null,
    }), itemSelector);

    const sameHeight = current.height === previousHeight;
    const sameCount = itemSelector == null || current.count === previousCount;
    stable = sameHeight && sameCount ? stable + 1 : 0;
    previousHeight = current.height;
    previousCount = current.count;
  }

  if (stable < stableRounds) {
    throw new Error('Scroll content did not become stable before the limit');
  }
}

(async () => {
  const browser = await puppeteer.launch({ headless: true });
  try {
    const page = await browser.newPage();
    await page.goto('https://example.com/feed', { waitUntil: 'domcontentloaded' });
    await loadUntilStable(page, { itemSelector: '.feed-item' });
    await page.screenshot({ path: 'page.png', fullPage: true });
  } finally {
    await browser.close();
  }
})();

Replace the example URL and selector with the target site’s actual values. Requiring both height and item-count stability can catch cases where items change without affecting page height. If no reliable item selector is available, omit itemSelector and treat height-only stability as a weaker heuristic. The loop throws if the page does not stabilize within its round limit; do not catch that error and silently take a screenshot as though completion were established.

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.

Adapt the loop for a nested scroll container

If a panel rather than the document scrolls, scroll that element and measure its own height and position. For example, the page-context operation can be adapted as follows:

await page.evaluate(() => {
  const panel = document.querySelector('.results-panel');
  if (!panel) throw new Error('Results panel not found');
  panel.scrollTop = panel.scrollHeight;
});

Use the real container selector and compare its scrollHeight and scrollTop, plus the rendered item count where possible. If the site uses a “load more” button, click it and wait for its loading state to finish or for the item count to increase; stop only when the site indicates there are no more results. A window scroll loop will not trigger a panel or button-based feed.

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

Wait for visual assets before capturing

Content being present in the DOM does not ensure every image or other visual asset is ready. After the feed’s completion condition succeeds, add checks tailored to the target markup for assets that matter to the screenshot. There is no universal image-readiness test established by the Puppeteer documentation cited here; lazy-loaded images, custom components, and layout shifts may need page-specific handling. Avoid assuming that a single fixed delay proves all visual content is ready.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Or skip the browser setup

ScreenshotNeo offers a screenshot API and MCP server. A single GET request can return a screenshot or PDF. For a URL whose page has already reached the state you want to capture, the API call is:

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.
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. The API can remove cookie/consent banners, newsletter popups, and chat widgets before capture; each of those steps can be turned off. Bot checks/CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed, and responses identify the page verdict and billing status in headers. 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 per month with no card; paid plans start at $5 for 3,000 shots.

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

Troubleshooting incomplete or stuck captures

  • The screenshot contains only the first batch: The page may require a scroll before loading. Scroll the actual document or panel, then wait for an item-count change or a real terminal signal.
  • The loop stops too soon: Stable height can be misleading if items fit into existing space. Track the feed’s item count or use an explicit end marker.
  • The loop never stabilizes: Live updates, rotating content, or layout shifts may keep changing measurements. Prefer an application-specific completion signal and retain a maximum round or time limit.
  • waitForNetworkIdle() times out: Persistent requests can prevent network idle. Treat it as optional settling, not the completion test; rely on the content condition instead.
  • Nothing loads after scrolling: Check whether scrolling is intercepted by a nested container, whether a button must be clicked, or whether the site’s script has reported an error.
  • Images are missing or shifted: The content condition may have succeeded before images or layout finished. Add asset checks suited to the page and capture only after those checks pass.
  • The end-marker wait times out: Confirm the selector in the live DOM and establish whether the marker is rendered only after all results. If the site has no marker, switch to a bounded count/height heuristic.

Runtime and reliability trade-offs

More scroll cycles and longer settling waits give delayed batches additional time to appear, but increase runtime. Explicit end markers and known counts are generally more reliable than inferring completion from unchanged height. Network-idle waits can add delay or time out on pages with persistent traffic, so use them only as a bounded aid. Always cap the loop and fail visibly when the chosen condition is not met; otherwise a partial screenshot can look like a successful capture.

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

Frequently Asked Questions

Does fullPage: true make Puppeteer load all infinite-scroll content?

No. It captures the full document that exists at capture time; it does not trigger future scroll-based loads.

Can I use networkidle2 as the infinite-scroll completion condition?

Not by itself. The page may become quiet between scroll-triggered batches, so pair any network-idle wait with a content-specific signal.

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
Crashes, No Sound, or Screen Glitches?Free driver scan
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.