To compare a website before and after a change, use Selenium to capture both versions in the same browser and page state, then use Pillow’s ImageChops.difference() to create a pixel-difference image. Inspect that image to locate changes; a summary score can help triage but cannot tell you whether a difference is a defect.
What you need
- Python, plus Selenium and Pillow installed in the project environment.
- A browser and a compatible Selenium driver, or a configured remote WebDriver.
- A stable test page, reference state and candidate state to compare.
Selenium’s Python WebDriver API documents saving a current-window screenshot as a PNG file or returning its PNG bytes. Pillow provides the image comparison and statistics operations used below. The linked API pages document Selenium 4.50.0 and 4.49.0 methods and Pillow 12.3.0; confirm availability against the releases installed in your project. Selenium WebDriver API, Pillow ImageChops, and Pillow ImageStat.
Capture comparable screenshots
The comparison is meaningful only if the captures represent the same conditions. Keep the route, viewport, scroll position and interaction state consistent. Where practical, also keep browser and operating-system versions, device scale, zoom, locale, color settings, authentication and page data stable. Wait for the content relevant to your test—including fonts or images—to settle before capturing.
- Install the dependencies:
python -m pip install selenium pillow. Install and configure the driver for your chosen browser, or configure your remote WebDriver. - Set the browser window size with Selenium’s
set_window_size(width, height). Use the same dimensions for both captures. - Navigate to the stable test URL and wait for the page condition you are testing. Capture the reference state, then repeat the same steps for the candidate state.
- Save both captures as PNGs, using Selenium’s
save_screenshot()orget_screenshot_as_file(). Selenium also documentsget_screenshot_as_png()for returning bytes andget_screenshot_as_base64()for base64 output.
from pathlib import Path
from selenium import webdriver
from selenium.webdriver.support.ui import WebDriverWait
URL = "https://example.com/your-test-page"
OUT = Path("screenshots")
OUT.mkdir(exist_ok=True)
# Configure the driver for the browser and environment used by your project.
driver = webdriver.Chrome()
try:
driver.set_window_size(1440, 1000)
driver.get(URL)
# Replace this with a condition that represents the page state under test.
WebDriverWait(driver, 20).until(
lambda d: d.execute_script("return document.readyState") == "complete"
)
driver.save_screenshot(str(OUT / "reference.png"))
# Apply the code/content change or load the candidate build, then repeat
# the same navigation and wait conditions before taking candidate.png.
# This example captures the current page again as a runnable starting point.
driver.save_screenshot(str(OUT / "candidate.png"))
finally:
driver.quit()
The example’s document-ready wait is only a starting condition; it does not guarantee that client-rendered content, web fonts, lazy images or animations have finished. Replace or extend it with the condition your page and test require. To capture separate builds, point the same procedure at each build while keeping the rest of the environment fixed.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
#1 Best Overall
- 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.
Generate and inspect a pixel difference
Load the PNGs with Pillow, check that their dimensions match, and convert them to the same compatible mode before comparing. ImageChops.difference(reference, candidate) returns an image containing the absolute pixel-by-pixel difference. Identical pixels appear black; changed areas show non-black values.
from PIL import Image, ImageChops, ImageStat
reference = Image.open("screenshots/reference.png").convert("RGB")
candidate = Image.open("screenshots/candidate.png").convert("RGB")
if reference.size != candidate.size:
raise ValueError(
f"Screenshot sizes differ: {reference.size} vs {candidate.size}"
)
diff = ImageChops.difference(reference, candidate)
diff.save("screenshots/difference.png")
stats = ImageStat.Stat(diff)
print("Per-channel mean difference:", stats.mean)
print("Review screenshots/difference.png for the location and shape of changes.")
Open difference.png and compare it with both original captures. The mean returned by ImageStat.Stat(diff).mean is the average arithmetic pixel level for each band. It is a summary, not a universal visual-regression pass percentage: a small changed region can matter greatly even when the overall mean is low, while widespread harmless antialiasing noise can raise it. Choose any threshold to fit your project and retain the diff image for diagnosis. Pillow documents the difference operation and per-band image statistics.
Rank #2
- 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.
Choose the right capture and comparison scope
| Choice | Use it for | Consider |
|---|---|---|
| Browser-window screenshot | Page layout and visible viewport content. | Keep window dimensions, scroll position and page state matched. Selenium documents current-window screenshot methods in its WebDriver API. |
| Element screenshot | A focused component, such as a card or navigation area. | The element’s own bounds are captured, but surrounding layout can still affect its rendering. Selenium documents element screenshot output as a PNG file or bytes in its WebElement API. |
| Difference image | Finding where pixels changed and visually diagnosing the change. | Keep it alongside the source captures; it shows locations, not causes or importance. |
| Summary statistic or project threshold | Automated triage across many captures. | Calibrate to the page and test goal; an aggregate can conceal a localized issue. |
| One state or broader coverage | One stable state keeps baseline maintenance smaller; multiple routes, viewports or interactions cover more user paths. | Choose coverage around user-critical behavior and maintain a distinct baseline for each tested condition. |
For noisy areas such as timestamps, ads or rotating content, prefer stable test data. If you mask a region, define it narrowly and only when that content is outside the purpose of the test; masking meaningful content can hide a real regression.
Troubleshoot common comparison problems
- The images have different dimensions: set the same Selenium window size for both captures and confirm the resulting image dimensions before calling the pixel operation.
- The diff contains changes in fonts or images that should be stable: wait on the relevant page condition rather than relying on a short arbitrary sleep. Ensure fonts and images have loaded before capture.
- The diff is noisy between runs: stabilize data and environment settings, including browser, operating system, device scale, locale and rendering configuration. Narrowly mask only known irrelevant regions.
- Pillow raises a mode or comparison error: convert both inputs deliberately to the same supported mode, such as
RGB, and ensure the sizes match. Pillow notes that most channel operations are implemented for 8-bit modes such asLandRGB. - The score looks small but a visible defect exists: inspect the difference image and original captures. The mean aggregates all pixels and can dilute a localized change.
- The score is large due to irrelevant animation or randomized content: freeze or control those inputs for the test, or exclude only narrowly defined regions that are not under test.
Or skip the browser setup
ScreenshotNeo is a website screenshot API and MCP server. A GET request can return a screenshot or PDF; its documented options include full-page and element capture, viewport and device presets, and custom waits. It accepts consent banners before capture and removes more than 60 known consent platforms, newsletter popups and chat widgets; those cleanup 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.
Outdated Drivers Are Slowing You Down
One free scan finds every outdated or missing driver and matches the right update for your exact hardware.Free scan · exact hardware matchWindows Errors? Fix Them Before They Spread
Repair common Windows errors and clear accumulated junk for a smoother, more stable PC - no reinstall needed.Free scan · no reinstallFor a direct capture, replace the example URL and provide your API key. The ScreenshotNeo API documentation describes the request options.
Rank #3
- 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.
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://example.com/your-test-page -o shot.webp
Python and Node.js equivalents:
import requests
r = requests.get(
"https://api.screenshotneo.com/v1/shot",
params={"access_key": "YOUR_API_KEY", "url": "https://example.com/your-test-page"},
timeout=90,
)
r.raise_for_status()
open("shot.webp", "wb").write(r.content)
const q = new URLSearchParams({
access_key: 'YOUR_API_KEY',
url: 'https://example.com/your-test-page'
});
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);
if (!res.ok) throw new Error(`Screenshot request failed: ${res.status}`);
await Bun.write('shot.webp', res);
Use the same URL and equivalent capture conditions for each version if you plan to compare the resulting images. ScreenshotNeo also provides an MCP server with take_screenshot, get_page_info and capture_pdf tools for AI agents. The Free plan includes 1,000 shots per month with no card; paid plans start at $5 for 3,000 shots. Sign up for free.
Frequently Asked Questions
Can a pixel difference tell me whether a change is a bug?
No. It identifies changed pixels; you need to inspect the captures and judge whether the change is expected and important.
Rank #4
- 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
Can I compare just one component instead of the whole viewport?
Yes. Selenium’s WebElement screenshot API documents PNG file and byte output for an element; compare those captures after keeping the element’s rendering conditions stable.
The Tool Desk
Outbyte PC Repair FREEClear out junk files and repair common Windows errorsFree Scan →Outbyte Driver Updater FREEFix the driver behind crashes, sound loss and screen glitchesFind Drivers →Quick Recap
Best Value
- 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.
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.

