October 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 NowOctober 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

Playwright: Capture a Full-Page Screenshot After Infinite Scroll Loads

Scroll and verify infinite-scroll content with page-specific signals before using Playwright’s fullPage screenshot option.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Scroll the page to trigger each infinite-scroll batch, and wait for a page-specific signal that the new content has rendered before capturing it. Then use await page.screenshot({ path: 'full-page.png', fullPage: true }). The fullPage option captures the full scrollable page; it does not, by itself, guarantee that an infinite list has loaded to its end.

Why fullPage does not finish infinite scrolling

fullPage: true controls the screenshot area: it captures the full scrollable page instead of only the visible viewport. Infinite scrolling is separate behavior, triggered as the page is scrolled or when a control is used. Playwright’s screenshot documentation does not promise that taking a full-page screenshot will trigger every site’s lazy-loading or infinite-scroll requests. Scroll and verify the content first, then capture. Playwright Page API

As an Amazon Associate I earn from qualifying purchases.

Choose a completion signal tied to the page

Prefer evidence that the content you need has arrived and rendered. Useful signals include a matching successful API response, a new card or row, an updated item count, a loading indicator disappearing, or an end-of-list marker. If a request is involved, register the response wait before triggering the scroll or click so the request is not missed. Playwright documents waiting for matching responses and observable page conditions. Playwright Waiting

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  • Request completed: confirms the relevant response arrived, but pair it with a DOM check if the screenshot needs the rendered result.
  • Item count increased: confirms new elements appeared; check for an end marker or another completion condition before stopping.
  • Loading state ended: useful when the site exposes a stable loading indicator.
  • End marker appeared: a strong stopping condition when the page provides one.

A fixed delay can be a fallback for a site with no better signal, but elapsed time alone does not establish that the intended batch loaded.

Runnable Playwright example

Replace the URL, selectors, and response predicate with signals from the target site. This example scrolls the last rendered item into view, waits for the matching response and an increase in item count, and stops at an end marker or the configured batch limit.

const itemSelector = '[data-testid="result-card"]';
const lastItemSelector = '[data-testid="result-card"]:last-child';
const endMarkerSelector = '[data-testid="end-of-results"]';
const apiPath = '/api/results';
const maxBatches = 20;

await page.goto('https://example.com/results');
await page.locator(itemSelector).first().waitFor({ state: 'visible' });

for (let i = 0; i < maxBatches; i++) {
  if (await page.locator(endMarkerSelector).isVisible().catch(() => false)) break;

  const before = await page.locator(itemSelector).count();
  const responsePromise = page.waitForResponse(response =>
    response.url().includes(apiPath) && response.ok()
  );

  await page.locator(lastItemSelector).scrollIntoViewIfNeeded();
  await responsePromise;
  await page.waitForFunction(
    ({ selector, previousCount }) =>
      document.querySelectorAll(selector).length > previousCount,
    { selector: itemSelector, previousCount: before }
  );
}

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

Install Playwright and configure the browser in your project before running this code. The example assumes each successful batch adds at least one matching item and that the API path identifies the request caused by scrolling. If the site uses a “Load more” button, click it instead of scrolling the last item. If it exposes no API request, remove the response wait and use a reliable DOM change, loading transition, or end marker. The maxBatches limit prevents an unbounded loop; choose a limit suitable for the page.

Why networkidle is not a general finish signal

Playwright defines networkidle as no network connections for at least 500 ms, and discourages using it to assess general test readiness. It measures network quiet, not whether a particular list reached its intended end. A page can be quiet between batches, or unrelated background traffic can continue after the content you need has rendered. Prefer a response, DOM change, loading-state transition, or end marker tied to the page. Playwright Page API

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

Capture and validate the result

After the page-specific stopping condition is met, capture the full scrollable page with fullPage: true. For a long feed, inspect the result to confirm that the final expected items appear and that the capture reflects the content state you intended. Infinite lists may have a documented end condition—or may continue indefinitely—so define what “complete” means for your use case, such as reaching an end marker or a known item count.

Keep visual comparisons reproducible

If you compare screenshots over time, keep the browser and capture environment consistent. Playwright notes that rendering can vary with host operating system, browser version, settings, hardware, power source, and headless mode. Its toHaveScreenshot() assertion waits until two consecutive page screenshots yield the same result before comparing them; this helps with screenshot stability but does not replace the page-specific loading checks above. Playwright Visual comparisons

Troubleshooting

The screenshot is short or misses later items

Cause: the page was captured before scrolling triggered the next batches, or before those batches rendered. Fix: scroll to the last item or use the page’s load control, then wait for an item-count change or another content-specific signal before capturing.

The response wait times out

Cause: the URL predicate does not match the actual request, scrolling did not trigger another batch, or the site uses a different loading mechanism. Fix: inspect the page’s requests and adjust the predicate; verify that the scroll target is valid; or replace the response wait with a stable DOM or loading-state condition.

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

The loop never reaches its end condition

Cause: the page has no detectable end marker, the selector is wrong, or content continues to load. Fix: use a known item count or the site’s documented completion rule where available, and retain a maximum-batch limit. Do not treat an arbitrary quiet period as proof that the feed is complete.

Visual diffs appear despite unchanged content

Cause: the rendering environment differs, or the page was captured at a different loading state. Fix: keep the browser environment consistent and wait for the same page-specific content conditions before each capture. Playwright Visual comparisons

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

Or skip the browser setup

For a one-call capture of a page, ScreenshotNeo is a website screenshot API and MCP server. It returns an image or PDF, but it does not replace this Playwright workflow when you need to drive a particular page through multiple infinite-scroll batches before capture.

See the ScreenshotNeo documentation for request options. Example cURL request:

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

ScreenshotNeo accepts cookie or consent banners and removes more than 60 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. Its MCP server provides take_screenshot, get_page_info, and capture_pdf tools for AI agents. The Free plan includes 1,000 shots per month without a card; paid plans start at $5 for 3,000 shots.

Sign up for 1,000 free screenshots a month, with no card 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 *

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
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.