DriversRecommendedOutdated drivers can make a good PC feel brokenScan driver issues before chasing fixes manually.Scan NowOctober 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 Scan×
Skip to content
World desk6 min

How to Screenshot an Infinite-Scroll Page with Selenium and Python

Selenium screenshots capture the current window, not content that has yet to load. Scroll the correct container, wait for the page's signal, then capture.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

To screenshot an infinite-scroll page with Selenium, first make the page load the content you want by scrolling through it and waiting for its loading behavior to finish. Then capture the result. A normal Selenium screenshot saves the current browser window; it does not make content farther down the page load automatically.

Why scrolling and screenshotting are separate steps

Infinite-scroll pages commonly fetch or render more content as a visitor approaches the bottom. Selenium can run JavaScript in the current page with execute_script or execute_async_script, which lets your script scroll and coordinate with page-specific behavior. But a screenshot command alone does not trigger that loading process. Selenium documents its window screenshot methods and script-execution APIs in the Python API documentation.

Use this sequence: open the page, wait for its initial content, identify the actual scroll container, scroll in bounded increments while waiting for new content, stop at a meaningful end condition, and only then take the screenshot. A fixed sleep can be useful for a quick experiment, but it is not reliable across sites with different loading behavior.

Identify what scrolls and what signals completion

Check the scroll container

Some pages scroll the browser window; others put the feed inside a nested element with its own scrollbar. Inspect the page in browser developer tools and look for the element whose scroll position changes as content loads. For a window-scrolling page, document.documentElement.scrollHeight is one possible measurement. It is not a universal indicator: nested containers, virtualized lists, and pages that replace old content can behave differently.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Sale
Logitech Brio 101 Full HD 1080p Webcam for Streaming and Meetings - Black
  • Compatible with Nintendo Switch 2’s new GameChat mode
  • Auto-Light Balance: RightLight boosts brightness by up to 50%, reducing shadows so you look your best—compared to previous-generation Logitech webcams (1)
  • Privacy with a Slide: The integrated webcam cover makes it easy to get total, reliable privacy when you're not on a video call
  • Built-In Mic: The built-in microphone lets others hear you clearly during video calls
  • Easy Plug-And-Play: The Brio 101 works with most video calling platforms, including Microsoft Teams, Zoom and Google Meet—no hassle; it just works

Choose a page-specific loading and stopping signal

Prefer a meaningful signal, such as a known end-of-results marker, a loading indicator disappearing after new items appear, or a change in the number of feed items. If no reliable site signal is available, use a bounded no-growth check: stop after several consecutive checks find no new content, and also impose a maximum number of iterations or elapsed time. Without both a suitable condition and a bound, a page that never settles can leave the script running indefinitely.

Load content before taking the screenshot

The following is an illustrative window-scroll pattern, not a universal solution. Replace the short polling pause with an explicit wait for the target page’s loading signal whenever possible. Adjust the content selector and termination rule for the site you are automating.

Rank #2
Sale
Logitech C270 720p Webcam Plug-and-Play Wide Screen Video Calling - Black
  • Compatible with Nintendo Switch 2’s new GameChat mode
  • Crisp HD 720p/30 fps video calls with diagonal 55° field of view and auto light correction. Compatible with popular platforms including Skype and Zoom.
  • The built-in noise-reducing mic makes sure your voice comes across clearly up to 1.5 meters away, even if you’re in busy surroundings.
  • C270’s RightLight 2 feature adjusts to lighting conditions, producing brighter, contrasted images to help you look good in all your conference calls.
  • The adjustable universal clip lets you attach the camera securely to your screen or laptop, or fold the clip and set the webcam on a shelf. You’re always ready for your next video call.
import time
from selenium.webdriver.support.ui import WebDriverWait

# Assumes driver has already opened the target page.
# Replace this with a meaningful initial-content condition for the site.
WebDriverWait(driver, 20).until(
    lambda d: d.execute_script(
        "return document.readyState"
    ) in ("interactive", "complete")
)

previous_height = 0
stable_checks = 0
max_iterations = 100

for _ in range(max_iterations):
    current_height = driver.execute_script(
        "return document.documentElement.scrollHeight"
    )

    if current_height == previous_height:
        stable_checks += 1
    else:
        stable_checks = 0
        previous_height = current_height

    if stable_checks >= 3:
        break

    driver.execute_script(
        "window.scrollTo(0, document.documentElement.scrollHeight)"
    )

    # Illustrative polling only. Prefer a WebDriverWait for the site's
    # loading indicator, item count, or end marker when one is known.
    time.sleep(1)
else:
    raise TimeoutError("Reached the scroll iteration limit before settling")

# Capture the loaded page from the top of the window.
driver.execute_script("window.scrollTo(0, 0)")
driver.save_screenshot("page.png")

The loop compares document height before and after scrolling and exits after three unchanged checks, with a maximum of 100 iterations. Those are example bounds, not values guaranteed to suit every site. If scrolling does not change document height, inspect whether the page uses a nested scroll element or virtualizes its content. Also note that reaching a stable height does not prove every image or asynchronous widget has finished rendering; wait for the relevant page-specific signal before capture.

Capture the loaded page: window screenshot or Chrome CDP

Standard Selenium window screenshot

driver.save_screenshot("page.png") captures the current browser window. Use it when a viewport-sized image is sufficient, or after positioning the window to the region you want. The related get_screenshot_as_file method also saves a window screenshot. Neither method, by itself, produces an entire long document as one image.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #3
Sale
NexiGo N60 1080P Webcam with Microphone, Software Control & Privacy Cover, USB HD Computer Web Camera, Plug and Play, for Zoom/Skype/Teams, Conferencing and Video Calling
  • 【Full HD 1080P Webcam】Powered by a 1080p FHD two-MP CMOS, the NexiGo N60 Webcam produces exceptionally sharp and clear videos at resolutions up to 1920 x 1080 with 30fps. The 3.6mm glass lens provides a crisp image at fixed distances and is optimized between 19.6 inches to 13 feet, making it ideal for almost any indoor use.
  • 【Wide Compatibility】Works with USB 2.0/3.0, no additional drivers required. Ready to use in approximately one minute or less on any compatible device. Compatible with Mac OS X 10.7 and higher / Windows 7, 8, 10 & 11 / Android 4.0 or higher / Linux 2.6.24 / Chrome OS 29.0.1547 / Ubuntu Version 10.04 or above. Not compatible with XBOX/PS4/PS5.
  • 【Built-in Noise-Cancelling Microphone】The built-in noise-canceling microphone reduces ambient noise to enhance the sound quality of your video. Great for Zoom / Facetime / Video Calling / OBS / Twitch / Facebook / YouTube / Conferencing / Gaming / Streaming / Recording / Online School.
  • 【USB Webcam with Privacy Protection Cover】The privacy cover blocks the lens when the webcam is not in use. It's perfect to help provide security and peace of mind to anyone, from individuals to large companies. 【Note:】Please contact our support for firmware update if you have noticed any audio delays.
  • 【Wide Compatibility】Works with USB 2.0/3.0, no additional drivers required. Ready to use in approximately one minute or less on any compatible device. Compatible with Mac OS X 10.7 and higher / Windows 7, 10 & 11, Pro / Android 4.0 or higher / Linux 2.6.24 / Chrome OS 29.0.1547 / Ubuntu Version 10.04 or above. Not compatible with XBOX/PS4/PS5.

Chromium capture beyond the viewport

For Chromium, Selenium’s Chrome driver can issue Chrome DevTools Protocol commands using execute_cdp_cmd. The CDP Page.captureScreenshot command accepts captureBeyondViewport; this can capture beyond the viewport when the desired content is already present in the rendered page. It does not load content that infinite scrolling has not yet caused the page to create. See Selenium’s Chrome driver API and the living Chrome DevTools Protocol Page reference.

import base64

result = driver.execute_cdp_cmd(
    "Page.captureScreenshot",
    {"format": "png", "captureBeyondViewport": True},
)
with open("page-full.png", "wb") as image_file:
    image_file.write(base64.b64decode(result["data"]))

The protocol supports PNG, JPEG, and WebP, as well as optional clipping. This example uses PNG and saves the returned base64 data. Confirm that the installed browser and Selenium combination supports the requested command parameters. This is a Chromium-specific option, unlike the ordinary WebDriver window screenshot method.

Rank #4
Sale
EMEET C960 1080P Webcam with Microphone, 2 Mics, 90° FOV, Computer Camera
  • 1080P Webcam with Cover for Video Calls - EMEET computer webcam provides design and Optimization for professional video streaming. Realistic 1920 x 1080p video, 5-layer anti-glare lens, providing smooth video. C960 computer camera delivers 1920x1080 video with fixed focus (11.8–118.1 inches), so as to provide a clearer image. C960 USB webcam has a cover and can be removed automatically to meet your needs for privacy. For optimal image performance, use the webcam in a well-lit environment.
  • Built-in 2 Omnidirectional Mics - EMEET webcam with microphone for desktop features 2 built-in omnidirectional microphones, picking up your voice to create clear audio for communication. When installing the webcam, select EMEET C960 as the default microphone input device in your computer and video applications and select C960 as the default device in Zoom/Teams and ensure microphone permissions are enabled for proper use. Please note that C960 does not include built-in speakers.
  • Automatic Light Adjustment - Automatic exposure adjustment is applied in EMEET HD webcam 1080p so that the streaming webcam can deliver stable image performance. EMEET C960 camera for computer also features color adjustment and exposure optimization to help you look your best. For optimal video quality, it is recommended to use the webcam in normal or well-lit environments and select suitable video settings in your application. Proper lighting helps achieve a clearer and more balanced image.
  • Plug-and-Play & Upgraded USB Connectivity - New C960 webcam features both USB Type-A & A-to-C adapter connections for wider compatibility. For stable performance, connect the webcam directly to the computer's main USB port and ensure the device is recognized correctly. If a hub or docking station is used, please ensure it provides sufficient power and stable data transmission, as limited ports may affect performance. 90° wide-angle lens captures more participants without frequent adjustments.
  • High Compatibility & Multi Application - C960 webcam for laptop is compatible with Windows 10/11, macOS 10.14+, and Android TV 7.0+. Not supported: Windows Hello, TVs, tablets, or game consoles. It works with Zoom, Teams, Facetime, Google Meet, YouTube and more. Please select C960 webcam as the default camera and microphone device in your application and ensure camera/microphone permissions are enabled, especially on macOS. (Tips: Incompatible with Windows Hello)
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Handle nested scroll containers

If the feed scrolls inside an element, scrolling the window will not reach its content. After identifying the element, use its selector and scroll that element instead. For example, if the page’s feed container has the CSS selector .feed, the basic JavaScript operation is:

driver.execute_script("""
const feed = document.querySelector('.feed');
if (!feed) throw new Error('Feed container not found');
feed.scrollTop = feed.scrollHeight;
""")

That snippet only moves the container; it does not wait for the site to load more items. Add a wait that observes the feed’s item count, loading indicator, or end marker, and apply the same iteration and time bounds as for window scrolling. For a screenshot, make sure the desired content is visible or already rendered; a standard window screenshot still captures the browser window, not an arbitrary full-length nested element.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Best Value
Logitech C920x HD Pro PC Webcam Full 1080p/30fps Video - Black
  • Compatible with Nintendo Switch 2’s new GameChat mode
  • HD lighting adjustment and autofocus: The Logitech webcam automatically fine-tunes the lighting, producing bright, razor-sharp images even in low-light settings. This makes it a great webcam for streaming and an ideal web camera for laptop use
  • Advanced capture software: Easily create and share video content with this Logitech camera that is suitable for use as a desktop computer camera or a monitor webcam
  • Stereo audio with dual mics: Capture natural sound during calls and recorded videos with this 1080p webcam, great as a video conference camera or a computer webcam
  • Full HD 1080p video calling and recording at 30 fps. You'll make a strong impression with this PC webcam that features crisp, clearly detailed, and vibrantly colored video

Common problems and fixes

  • The screenshot contains only the first screen: the capture happened before scrolling triggered more content, or the page uses a nested scroll container. Scroll the correct container and wait for new content before capturing.
  • The loop stops too early: document height may stay constant while a nested feed changes, or a site may replace content in place. Track a page-specific item count or loading state instead of relying only on document height.
  • The loop never ends: continuously changing content, ads, or delayed updates can prevent a no-growth condition. Add a hard iteration or time limit and use an explicit end marker when the page provides one.
  • Content is missing despite a long wait: a delay cannot guarantee that the relevant request or rendering completed. Wait for a meaningful element or loading signal, and check whether the site requires authentication or a user action.
  • The CDP call fails or ignores an option: check that the driver is Chromium-based and that the installed browser and Selenium versions support the command and parameter. Use the standard window screenshot method if beyond-viewport capture is unavailable.
  • The image is impractically large: very long pages can produce large images, and browser behavior varies by page and browser. Consider capturing in sections or using a PDF workflow if one extremely tall image is not useful; no universal maximum height is established by these APIs.

Or skip the browser setup

ScreenshotNeo is a website screenshot API and MCP server. One GET request can return a PNG, JPEG, WebP, or PDF. Cookie banners are accepted and removed before capture along with 60+ known consent platforms, newsletter popups, and chat widgets; each cleanup step can be turned off. Bot checks or CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed, and response headers report the page verdict and billing status. AI agents can use its MCP server tools, including take_screenshot, get_page_info, and capture_pdf.

For a single call, replace the URL with the page you want to capture and supply your API key. See the ScreenshotNeo API documentation.

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

The free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000 screenshots. Sign up for free.

Frequently Asked Questions

Does Selenium automatically load every item on an infinite-scroll page?

No. Your automation must scroll the page or its actual feed container and wait for the site’s content-loading behavior.

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.

Can I use captureBeyondViewport with Firefox?

The documented Page.captureScreenshot option is part of the Chromium DevTools Protocol and is invoked here through Selenium’s Chrome driver.

Quick Recap

SaleBestseller No. 1
Logitech Brio 101 Full HD 1080p Webcam for Streaming and Meetings - Black
Logitech Brio 101 Full HD 1080p Webcam for Streaming and Meetings - Black
Compatible with Nintendo Switch 2’s new GameChat mode; Built-In Mic: The built-in microphone lets others hear you clearly during video calls
$35.80
SaleBestseller No. 2
Logitech C270 720p Webcam Plug-and-Play Wide Screen Video Calling - Black
Logitech C270 720p Webcam Plug-and-Play Wide Screen Video Calling - Black
Compatible with Nintendo Switch 2’s new GameChat mode
$16.89
Bestseller No. 5
Logitech C920x HD Pro PC Webcam Full 1080p/30fps Video - Black
Logitech C920x HD Pro PC Webcam Full 1080p/30fps Video - Black
Compatible with Nintendo Switch 2’s new GameChat mode; Fully compatible with Windows 11
$69.99

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
Windows Errors? Fix Them Before They SpreadFree repair scan
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.