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

Selenium can capture a screenshot of the current page or a specific element, but it does not by itself provide a complete visual snapshot-testing workflow. For that, capture a known page state, compare it with an accepted baseline using a separate comparison library or service, inspect the differences, and approve a new baseline only when the change is intentional.

What “snapshot testing” means in Selenium

In visual regression testing, a snapshot is an image of a page or element at a particular point in a test. The image is compared with a previously accepted baseline to detect unexpected visual changes. Applitools describes visual testing as regression testing that checks whether previously correct screens have changed unexpectedly (Applitools, “Overview of Visual UI Testing”).

The term can also mean a structural snapshot, such as an accessibility-tree representation asserted against expected content. That is a different artifact from a screenshot; Playwright documents ARIA snapshots separately from visual screenshot comparisons (Playwright ARIA snapshots).

Selenium WebDriver supplies the browser automation and screenshot capture. Baseline storage, image comparison, difference thresholds, review, and approval are responsibilities of the surrounding test workflow or a visual-testing tool.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Elebase USB to USB C Adapter for iPhone 18 Pro Max,USBC Car Charger Adapter
  • Read Before You Buy — No Video Output: These adapters support charging and USB 2.0 data transfer, but cannot transmit video signals. Except for standard USB webcams (which use USB data only), they are not compatible with HDMI/DisplayPort cables, video-capable USB-C hubs, or docking stations with video output.
  • Convert USB-A Ports to USB-C: Designed to connect USB-C earphones, cables, flash drives, card readers, and other USB-C accessories to standard USB-A ports. Plug-and-play with no drivers or software required.
  • Aluminum Alloy Housing: Built with a sturdy aluminum alloy shell that aids in heat dissipation and protects against daily wear and scratches. Designed to maintain a stable and secure connection.
  • Compact & Travel-Friendly: The ultra-compact design allows the adapter to stay plugged into your device without blocking adjacent ports or adding bulk, reducing wear and tear on your original USB ports.
  • 12-Month Warranty: Backed by a 12-month manufacturer warranty for peace of mind. Designed to meet strict quality control standards for reliable everyday performance.

Build a visual snapshot test in four steps

1. Make the page state reproducible

Navigate to the page with stable test data and wait for the content that matters. Use a consistent viewport and browser configuration, and avoid capturing while animations, asynchronous updates, or transient overlays are still changing the page. If some content is inherently dynamic, isolate it or exclude it from the comparison where your chosen tooling permits.

Decide the capture scope before writing the assertion:

Rank #2
Anker USB-C Hub, 5-in-1 USB Hub for Laptops, 4K HDMI Multiport Adapter
  • 5-in-1 USB-C Hub: Experience comprehensive connectivity featuring a Power Delivery input, two USB-A 2.0 ports, a USB-A 3.0 port, and an HDMI port. (Note: The USB-C power delivery input port is only for connecting an external wall charger to power your laptop and cannot power peripheral devices.)
  • 90W Pass-Through Charging: Achieve optimal charging with 90W pass-through power to your laptop, supported by a total input of 100W, with the hub reserving 10W for operational efficiency. (Note: Wall charger not included.)
  • Quick Data Transfers: Accelerate your productivity with rapid data transfers using a high-speed 5Gbps USB 3.0 port and two 480Mbps USB 2.0 ports.
  • 4K HDMI Display: Enhance your visual experience with a hub capable of delivering 4K resolution at 30Hz in both mirror and extend modes. Please note that this hub is compatible with MacBook (macOS 12 and newer), Windows 10 and 11, ChromeOS, and laptops equipped with DP Alt Mode and Power Delivery. Note: This device is not compatible with Linux.
  • What You Get: Anker USB-C Hub (5-in-1, 4K HDMI), welcome guide, 18-month warranty, and our friendly customer service.
  • Viewport: the currently visible browser area; useful for a specific screen layout.
  • Element: one component or region; useful when unrelated page changes should not affect the test.
  • Whole page: the full document where the binding or capture method supports it and that is what you intend to validate.

2. Capture with WebDriver

The following Python example uses Selenium’s WebDriver screenshot API to save a viewport screenshot. Install Selenium with python -m pip install selenium, configure a driver supported by your environment, and set BASELINE_DIR to a directory containing a reviewed baseline named home.png.

from pathlib import Path
from selenium import webdriver
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.ui import WebDriverWait

BASELINE_DIR = Path("visual-baselines")
ARTIFACT_DIR = Path("artifacts")
ARTIFACT_DIR.mkdir(exist_ok=True)

options = webdriver.ChromeOptions()
options.add_argument("--window-size=1440,1000")

driver = webdriver.Chrome(options=options)
try:
    driver.get("https://example.com")
    WebDriverWait(driver, 15).until(
        EC.visibility_of_element_located(("css selector", "main"))
    )

    candidate = ARTIFACT_DIR / "home.png"
    if not driver.save_screenshot(str(candidate)):
        raise RuntimeError("WebDriver did not save the screenshot")

    baseline = BASELINE_DIR / "home.png"
    if not baseline.exists():
        raise FileNotFoundError(
            f"No accepted baseline at {baseline}; review the candidate before creating one"
        )
    print(f"Candidate saved to {candidate}; compare it with {baseline}")
finally:
    driver.quit()

This example deliberately stops after capture: Selenium does not define a built-in baseline comparison or approval policy. Add the comparison step supplied by your chosen image-diff library or visual-testing service. Selenium’s official documentation demonstrates both page and element screenshot capture and describes screenshot data in supported bindings (Selenium: TakeScreenshot and TakeElementScreenshot).

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #3
Sale
Anker USB C Hub, 7in1 Multi-Port USB Adapter, 4K@60Hz USBC to HDMI Splitter
  • Sleek 7-in-1 USB-C Hub: Features an HDMI port, two USB-A 3.0 ports, and a USB-C data port, each providing 5Gbps transfer speeds. It also includes a USB-C PD input port for charging up to 100W and dual SD and TF card slots, all in a compact design.
  • Flawless 4K@60Hz Video with HDMI: Delivers exceptional clarity and smoothness with its 4K@60Hz HDMI port, making it ideal for high-definition presentations and entertainment. (Note: Only the HDMI port supports video projection; the USB-C port is for data transfer only.)
  • Double Up on Efficiency: The two USB-A 3.0 ports and a USB-C port support a fast 5Gbps data rate, significantly boosting your transfer speeds and improving productivity.
  • Fast and Reliable 85W Charging: Offers high-capacity, speedy charging for laptops up to 85W, so you spend less time tethered to an outlet and more time being productive.
  • What You Get: Anker USB-C Hub (7-in-1), welcome guide, 18-month warranty, and our friendly customer service.

For an element-scoped capture in Python, wait for the target element and save its screenshot instead of the page image:

from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC

card = WebDriverWait(driver, 15).until(
    EC.visibility_of_element_located((By.CSS_SELECTOR, "main .product-card"))
)
if not card.screenshot("artifacts/product-card.png"):
    raise RuntimeError("WebDriver did not save the element screenshot")

Bindings differ in method names and returned representation; consult the Selenium documentation for the language in use. Some WebDriver APIs return screenshot data as Base64, which you can decode and save as an image.

Rank #4
Sale
UGREEN USB to USB C Adapter Combo 4-Pack, 10Gbps USB C Converter Space Gray
  • Dual Converters, Infinite Potential:Includes 2× USB C male to USB A female adapters and 2× USB A male to USB C female adapters. Perfect for a wide range of uses—tablets with Bluetooth keyboards, expand USB ports on macbook, and more. Two different converters for all your daily needs
  • Next-Level 10Gbps & 3A Charging: No more slow 480Mbps, this usb to usb c adapter has a transfer speed of up to 10Gbps, allowing you to do more transferring in less time. This usb adapter fits both USB A and USB C charger, supporting up to 3A fast charging
  • Upgraded Exquisite Craftsmanship: With an aluminum alloy housing and metal connector, the usbc to usb adapter is extremely durable and sturdy. Rigorously tested to withstand more than 10,000 times of plugging and unplugging, ensuring long-lasting performance
  • Broad Compatible: The usb c to usb adapter widely supports all USB C/ USB A devices like laptops, tablets, cellphones, car chargers, and phone chargers. Such as compatible with MacBook Pro/Air 2023/2022, Thunderbolt 4/3 Devices,Apple MagSafe Watch 9/8/7/SE/Ultra, iPad Pro 2022/2021, Samsung Galaxy S23/S20/S10, and iPhone 17/16/15 Pro. Plug and play
  • Please Note: To reach 10Gbps speed, keep the cable under 3.3 ft. For USB A Male to USB C adapters, try flipping the USB C connector. USB C Male to USB A adapters support bidirectional 10Gbps transfer within 3.3 ft

3. Compare candidate and baseline

Use a comparison implementation that fits your stack. Common decisions include whether to compare pixels or use perceptual analysis, how to treat antialiasing differences, and what threshold constitutes a failure. The right tolerance depends on the page and environment; do not adopt a broad threshold merely to make flaky tests pass. Keep the baseline files under version control or use the storage and history provided by your selected service.

4. Review the diff before changing the baseline

When a comparison fails, inspect the candidate, baseline, and difference image or review screen. Determine whether the change is a defect, a test-environment variation, or an intentional UI update. Accept a replacement baseline only after review. Visual-testing workflows commonly use this review-and-approval cycle; Applitools describes visual testing for websites and web applications in its documentation (Applitools: Visual Testing for Websites and Web Applications).

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Best Value
Anker USB C Hub, 5-in-1 USBC to HDMI Splitter with 4K Display
  • 5-in-1 Connectivity: Equipped with a 4K HDMI port, a 5 Gbps USB-C data port, two 5 Gbps USB-A ports, and a USB C 100W PD-IN port. Note: The USB C 100W PD-IN port supports only charging and does not support data transfer devices such as headphones or speakers.
  • Powerful Pass-Through Charging: Supports up to 85W pass-through charging so you can power up your laptop while you use the hub. Note: Pass-through charging requires a charger (not included). Note: To achieve full power for iPad, we recommend using a 45W wall charger.
  • Transfer Files in Seconds: Move files to and from your laptop at speeds of up to 5 Gbps via the USB-C and USB-A data ports. Note: The USB C 5Gbps Data port does not support video output.
  • HD Display: Connect to the HDMI port to stream or mirror content to an external monitor in resolutions of up to 4K@30Hz. Note: The USB-C ports do not support video output.
  • What You Get: Anker 332 USB-C Hub (5-in-1), welcome guide, our worry-free 18-month warranty, and friendly customer service.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Keep screenshot comparisons reliable

Control the rendering environment

Generate baselines and candidates in the same browser and host environment where possible. Rendering can vary with operating system, browser version, settings, hardware, power source, and headless mode; Playwright’s visual-comparison guidance calls out these sources of variation (Playwright visual comparisons). Pinning the browser version and running baseline generation and CI comparison in a consistent environment reduces noise, but does not guarantee identical rendering across all machines.

Stabilize only what the test needs

  • Wait for the specific content under test rather than relying only on a fixed sleep.
  • Use deterministic test data and a known application state.
  • Choose a fixed viewport and capture scope.
  • Prevent or accommodate animation and frequently changing content when the comparison tool supports it.
  • Keep setup, capture, comparison, and baseline approval distinct so a failed assertion does not silently overwrite the reference image.

Choose a workflow that matches the team

A local image-diff implementation can be sufficient when the team only needs artifacts and a simple pass/fail check. A hosted visual-testing service may be useful when reviewers need a managed interface for inspecting changes or a broader visual-testing workflow. Applitools Eyes is one such category example with documented visual-testing workflows and Selenium integration; its suitability depends on your requirements, and this is not a hands-on product evaluation.

Compare implementations by capture scope, baseline location and approval process, comparison controls, dynamic-content handling, cross-browser needs, CI integration, and whether a local artifact workflow is enough. Selenium handles capture; these other capabilities depend on the comparison library or service selected.

Troubleshooting Selenium snapshot tests

  • The screenshot is blank or incomplete: verify navigation completed, wait for the relevant visible content, and check that the test is on the intended page and state.
  • The test fails intermittently: replace arbitrary timing assumptions with waits for the actual condition; stabilize data and changing page regions.
  • Every run reports visual differences: check browser version, operating system, headless mode, viewport, and other environment settings for consistency.
  • An element screenshot fails: confirm the selector matches an element that is present and visible before invoking its screenshot method.
  • The baseline is missing: create a candidate artifact, review it as the expected state, then add it through the team’s explicit baseline-approval process.
  • A new baseline hides a real regression: avoid automatic baseline replacement on test failure; inspect the difference and approve changes deliberately.

Or skip the browser setup

If you need a clean screenshot without managing Selenium and a browser driver, ScreenshotNeo is a website screenshot API and MCP server. One GET request returns an image or PDF. Its capture flow accepts cookie or consent banners like a visitor and removes more than 60 known consent platforms, newsletter popups, and chat widgets; these steps can be disabled. Bot checks, blank pages, timeouts, failed loads, and cache hits are not billed, with response headers indicating the page verdict and billing status. Its MCP server provides screenshot, page-info, and PDF tools for AI agents. The Free plan includes 1,000 screenshots per month without a card; paid plans start at $5 for 3,000 shots. See the ScreenshotNeo API documentation.

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.
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://example.com -o shot.webp

Sign up for ScreenshotNeo’s free plan: 1,000 screenshots a month, 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.