October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsWindows FixRecommendedWindows errors stealing your time? Find the fix fastScan stability, cleanup and performance issues.Fix 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

How to Create Website Thumbnails with Selenium WebDriver

A practical Selenium guide to viewport and element thumbnails, Chrome-specific full-page capture, output formats, and screenshot troubleshooting.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Use Selenium WebDriver to open a page, set the browser viewport to the framing you want, wait for the content your thumbnail needs, and save a screenshot. The basic screenshot captures the current browser view—not automatically the whole document. For a single card or other region, capture the element itself; for a full-page image, use a browser-specific method such as Chrome’s DevTools Protocol.

Capture a website thumbnail in Python

This example uses headless Chrome, sets a deliberate viewport, waits for a visible page heading, and saves the current browser view as a PNG. Selenium documents save_screenshot() for the current browsing context; its Python API returns false if it encounters an I/O error.

from selenium import webdriver
from selenium.webdriver.support.ui import WebDriverWait

options = webdriver.ChromeOptions()
options.add_argument("--headless")

driver = webdriver.Chrome(options=options)
try:
    driver.set_window_size(1280, 800)
    driver.get("https://example.com")

    # Replace this with a condition that represents the content you need.
    WebDriverWait(driver, 10).until(
        lambda d: d.find_element("tag name", "h1").is_displayed()
    )

    if not driver.save_screenshot("thumbnail.png"):
        raise OSError("Could not save thumbnail.png")
finally:
    driver.quit()

Install Selenium and a compatible Chrome/ChromeDriver setup before running the script. Selenium’s WebDriver documentation covers browser setup and screenshot examples.

Choose the framing before capture

set_window_size(width, height) controls the browser window dimensions. Adjust these values to suit the intended thumbnail; 1280 by 800 in the example is a chosen viewport, not a universal thumbnail standard. A different viewport can change responsive layouts, so use dimensions that match the preview or test you need.

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.

Wait for the content, not just navigation

In Selenium Python, get() waits for the page’s onload event. That does not guarantee that content loaded or changed asynchronously afterward is ready for a screenshot. The example waits for a visible h1 as a basic illustration. Replace it with a condition tied to the target content or your application’s own stable state; a visible heading alone does not prove that every image, animation, or data request has finished.

Capture one element instead of the viewport

If the thumbnail should show one card, hero, or other page region, locate that element and call its screenshot method rather than saving the whole browser view:

element = driver.find_element("css selector", ".product-card")
element.screenshot("card.png")

Change .product-card to a selector that identifies the element on your page. The element must be locatable, and the browser implementation determines the capture behavior. Selenium’s screenshot examples include a separate element screenshot method alongside screenshots of the current browsing context.

Capture beyond the viewport in Chrome

A regular WebDriver screenshot should be treated as a screenshot of the current view, not as a promise to capture the entire document. For Chrome-specific full-page control, Chrome DevTools Protocol’s Page.captureScreenshot supports clipping and the captureBeyondViewport parameter, which defaults to false in the protocol reference. Selenium’s Python Chromium driver exposes execute_cdp_cmd() for sending DevTools Protocol commands.

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

The following illustrates the command shape for Chrome. It captures beyond the viewport and returns the image as base64 data; decode and save that data as needed by your application.

import base64

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

This is Chrome-specific, not a portable Selenium screenshot method. DevTools Protocol support can vary with the installed Chrome and Selenium versions, so check compatibility in the environment where the script will run. The protocol also supports a clip when you need a defined region rather than a full-page capture.

Choose an output format and handling method

  • PNG file: Python’s save_screenshot("thumbnail.png") is the straightforward documented route for a current-window screenshot. Selenium also provides screenshot bytes and base64 output in its API.
  • Element image: Python’s element.screenshot("element.png") saves the selected element’s screenshot.
  • JavaScript output: Selenium’s JavaScript examples expose screenshot data as base64, which you can decode or pass to another part of your program.
  • Chrome protocol formats: Chrome DevTools Protocol lists PNG, JPEG, and WebP. Its quality parameter applies to JPEG.

Use PNG when a simple documented file output is sufficient. Choose JPEG or WebP only when using a method that supports those formats and your downstream workflow needs them.

Run headless Chrome from the command line

For a quick Chrome-only capture without writing a Selenium script, Chrome’s headless command-line option can write a screenshot in the current working directory:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
chrome --headless --window-size=1280,800 --screenshot="screenshot.png" https://example.com

Use the executable name and any required environment-specific options for your Chrome installation. Chrome documents --window-size for setting dimensions and notes that full-page screenshots require more than the basic command-line screenshot option.

Troubleshoot common thumbnail problems

The image shows a loading state or missing content

get() reaching the page’s onload event is not the same as all asynchronous content being visually ready. Wait for a target element or an application-specific ready condition before capturing. If the page replaces or animates content later, make the wait reflect the state you actually want in the thumbnail.

The screenshot is cropped or framed incorrectly

Check the window dimensions set before navigation and capture. Responsive pages can render different layouts at different sizes. A viewport screenshot contains the current browser view; use element capture for a single region or Chrome’s DevTools Protocol when you need clipping or beyond-viewport capture.

The output file is missing

Use a writable location and, when necessary, an absolute path. Selenium Python documents that save_screenshot() returns false on an I/O error. Check that return value and confirm the process has permission to write the destination file.

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

The DevTools command fails

execute_cdp_cmd() sends Chrome DevTools Protocol commands, so it is not a general cross-browser solution. Confirm that the driver is a Chromium driver, that the command and parameters are supported by the installed Chrome version, and that the Selenium binding exposes the method in your setup.

Results differ across environments

The cited Selenium and Chrome documentation does not establish identical screenshot output across browser engines or operating systems. Validate representative pages using the same browser and deployment environment as the thumbnail job, especially when layout, fonts, or dynamic content matter.

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 one-request screenshot API when you do not want to configure and manage a browser for captures. It can return PNG, JPEG, WebP, or PDF; see the ScreenshotNeo API documentation for request options.

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

ScreenshotNeo accepts cookie or consent banners before capture and removes 60+ known consent platforms, newsletter popups, and chat widgets; each of those steps 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. Its MCP server provides take_screenshot, get_page_info, and capture_pdf tools for AI agents. The free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000 screenshots.

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

Sign up for ScreenshotNeo’s free plan to try it without a card.

Sources

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. Shenzhen desk3 min
    HONOR Expands Beyond Smartphones With Humanoid Robot RevealHONOR said it unveiled its first humanoid robot at MWC 2026 and named shopping assistance, workplace inspections, and supportive companionship as intended uses. Later Robotics D1 claims and a reported…
  2. Cupertino desk5 min
    Apple Unveils AirPods Max 2: The Upgrade That Should Have Happened Years AgoAirPods Max 2 adds H2-powered audio features and Apple claims up to 1.5× more effective ANC, but its design, Smart Case, and 20-hour battery rating are unchanged. Wired lossless audio…
  3. Cupertino desk4 min
    Apple’s OLED Touch MacBooks Are Coming—but the Dynamic Island Is the Real GambleApple has not announced an OLED touchscreen MacBook, but reports point to high-end models arriving in late 2026 or early 2027. The reported Mac Dynamic Island could be useful, but…
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.