What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
Some links on this page are affiliate links: if you buy through them we may earn a commission, at no extra cost to you.
Set the active WebDriver window before loading the page or taking the image. In Python, the basic pattern is driver.set_window_size(1024, 768), followed by navigation and driver.save_screenshot("screenshot.png"). The requested outer window is not always identical to the CSS viewport or the final image, so verify the effective size in the browser and inspect the saved artifact in the environment where the test runs.
Set the size before taking the screenshot
This complete Python example opens Chrome, requests a 1024×768 window, loads the page, captures the current window, and closes the driver:
from selenium import webdriver
options = webdriver.ChromeOptions()
# options.add_argument("--headless=new") # Enable when a visible window is not needed.
driver = webdriver.Chrome(options=options)
try:
driver.set_window_size(1024, 768)
driver.get("https://example.com")
driver.save_screenshot("screenshot.png")
finally:
driver.quit()
set_window_size(width, height) uses pixels and changes the current WebDriver window. Put it before get() when the page’s initial responsive layout, media queries, or JavaScript measurements must be evaluated at that size. Putting it immediately before the screenshot is also valid when the page has already loaded, but a resize can trigger a new responsive layout, so wait for the resulting state before capturing.
Window size, viewport size, and image size are different
A browser window has an outer rectangle that includes browser chrome in a headed session. The CSS viewport is the area available to the document, and the screenshot is the rendered output returned by the driver. Operating-system window managers, browser differences, scaling, and headless implementation can make these values differ. A request for 1024×768 therefore is not a universal promise that the page’s CSS viewport or PNG dimensions will be exactly 1024×768.
#1 Best Overall
- CRISP CLARITY: This 23.8″ Philips V line monitor delivers crisp Full HD 1920x1080 visuals. Enjoy movies, shows and videos with remarkable detail
- INCREDIBLE CONTRAST: The VA panel produces brighter whites and deeper blacks. You get true-to-life images and more gradients with 16.7 million colors
- THE PERFECT VIEW: The 178/178 degree extra wide viewing angle prevents the shifting of colors when viewed from an offset angle, so you always get consistent colors
- WORK SEAMLESSLY: This sleek monitor is virtually bezel-free on three sides, so the screen looks even bigger for the viewer. This minimalistic design also allows for seamless multi-monitor setups that enhance your workflow and boost productivity
- A BETTER READING EXPERIENCE: For busy office workers, EasyRead mode provides a more paper-like experience for when viewing lengthy documents
For pixel-sensitive visual tests, record the browser, driver, operating system, headless mode, requested rectangle, effective viewport, and screenshot dimensions with the test result. Verify the actual artifact rather than assuming the requested number was applied exactly.
Read back the effective window
driver.set_window_size(1024, 768)
print("window:", driver.get_window_size())
print("viewport:", driver.execute_script(
"return {width: window.innerWidth, height: window.innerHeight, "
"devicePixelRatio: window.devicePixelRatio};"
))
get_window_size() reports the WebDriver window dimensions. The JavaScript values report the document viewport as seen by the page. Device-pixel ratio helps explain why CSS pixels and bitmap pixels may not match.
Choose the Selenium window API
Python: set_window_size
driver.set_window_size(800, 600)
# or
size = driver.get_window_size()
This is the straightforward Python method when only width and height matter.
Windows 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 reinstallOutdated 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 matchRank #2
- CRISP CLARITY: This 22 inch class (21.5″ viewable) Philips V line monitor delivers crisp Full HD 1920x1080 visuals. Enjoy movies, shows and videos with remarkable detail
- 100HZ FAST REFRESH RATE: 100Hz brings your favorite movies and video games to life. Stream, binge, and play effortlessly
- SMOOTH ACTION WITH ADAPTIVE-SYNC: Adaptive-Sync technology ensures fluid action sequences and rapid response time. Every frame will be rendered smoothly with crystal clarity and without stutter
- INCREDIBLE CONTRAST: The VA panel produces brighter whites and deeper blacks. You get true-to-life images and more gradients with 16.7 million colors
- THE PERFECT VIEW: The 178/178 degree extra wide viewing angle prevents the shifting of colors when viewed from an offset angle, so you always get consistent colors
Python: set_window_rect
driver.set_window_rect(x=0, y=0, width=1024, height=768)
rect = driver.get_window_rect()
print(rect)
set_window_rect combines position and dimensions. Selenium’s Python API documents it for W3C-compatible browsers; for other browsers, use the separate position and size methods supported by that driver. The position is useful when several visible browser windows are being arranged, but it does not make screenshot pixels more reproducible by itself.
Java
import org.openqa.selenium.Dimension;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
WebDriver driver = new ChromeDriver();
try {
driver.manage().window().setSize(new Dimension(1024, 768));
driver.get("https://example.com");
((org.openqa.selenium.TakesScreenshot) driver)
.getScreenshotAs(org.openqa.selenium.OutputType.FILE);
} finally {
driver.quit();
}
Use driver.manage().window().setSize(new Dimension(width, height)) before navigation or capture.
JavaScript (Node.js Selenium binding)
const { Builder } = require('selenium-webdriver');
(async function () {
const driver = await new Builder().forBrowser('chrome').build();
try {
await driver.manage().window().setRect({ width: 1024, height: 768 });
await driver.get('https://example.com');
await driver.takeScreenshot();
} finally {
await driver.quit();
}
})();
The JavaScript API uses setRect for the window rectangle. Store the returned base64 data or write it to a file when you need a persistent image.
Rank #3
- Clear visuals. Fluid motion: A 144Hz refresh rate and 1ms MPRT deliver smooth, tear‑free motion across work, gaming, and streaming for clearer, more fluid viewing.
- Eye comfort: TÜV Rheinland 3‑star* certification reduces harmful blue light while preserving stunning color quality without compromise. *TÜV Rheinland 3-star eye comfort certification.
- Wide viewing angle: Get consistent views across a wide 178° /178° viewing angle.
- In-Plane Switching (IPS): See excellent color accuracy and consistency across wide viewing angles with In-plane Switching (IPS) technology.
- Ultra-thin bezels: Maximize your viewing experience with thin bezels.
C#
using OpenQA.Selenium;
using OpenQA.Selenium.Chrome;
IWebDriver driver = new ChromeDriver();
try
{
driver.Manage().Window.Size = new System.Drawing.Size(1024, 768);
driver.Navigate().GoToUrl("https://example.com");
((ITakesScreenshot)driver).GetScreenshot().SaveAsFile("screenshot.png");
}
finally
{
driver.Quit();
}
Capture the right scope
Current-window screenshot
The ordinary screenshot methods capture what is visible in the current browser window. They do not automatically stitch every document section below the fold. A taller requested window can show more content, but it does not establish full-document capture.
The Tool Desk
Outbyte Driver Updater FREEFix the driver behind crashes, sound loss and screen glitchesFind Drivers →Outbyte PC Repair FREERepair Windows errors before they cause bigger problemsFix Now →Full-document screenshot
If you need the entire page, use a full-page method explicitly supported by the browser and Selenium binding you run. Firefox’s Python API documents separate full-document screenshot methods. Availability and behavior are browser- and driver-specific, so test the exact combination used by CI. If no supported full-page method exists, a scrolling-and-stitching implementation is a different workflow and must account for fixed headers, lazy loading, animations, and duplicate pixels.
Reliable screenshot procedure
- Create the driver. Pin the browser and driver versions used by your test environment where practical.
- Set the rectangle. Call
set_window_sizeorset_window_rectimmediately after driver creation. - Verify it. Read
get_window_size()and, when layout matters, querywindow.innerWidth,window.innerHeight, anddevicePixelRatio. - Navigate. Load the target URL after sizing so the initial responsive state uses the intended dimensions.
- Wait for readiness. Use an explicit wait for a meaningful element or application state instead of an arbitrary short sleep. Wait for fonts, images, and asynchronous content that affect the visual assertion.
- Stabilize the page. Disable or wait out animations, close obstructive dialogs, and scroll only when your chosen capture method requires it.
- Capture. Save the current window or invoke the binding’s documented full-page method.
- Validate the artifact. Check that the file exists, opens, has the expected dimensions, and represents the intended state.
- Quit in a finally block. This prevents leaked browser processes after assertion failures.
Common problems and fixes
The screenshot is not 1024×768
- Cause: You requested the outer window, while the screenshot reports a viewport or device-pixel dimension.
- Fix: Log both
get_window_size()and JavaScript viewport values, inspect device-pixel ratio, and compare artifacts from the same browser, driver, OS, and headless mode.
The layout uses the wrong breakpoint
- Cause: The page was loaded before resizing, or a resize-triggered application update had not completed.
- Fix: Set dimensions before
get(); after resizing, wait for the relevant element or class to reach its expected state before capture.
The browser refuses the requested rectangle
- Cause: A driver, browser, OS window manager, remote session, or headless mode may constrain window operations.
- Fix: Read back the effective rectangle, use a supported W3C-compatible API, and configure the remote or headless environment consistently. Do not silently treat the requested value as proof of the rendered size.
The image contains only the visible part of a long page
- Cause: Standard screenshot calls capture the current window, not the entire document.
- Fix: Use an explicitly supported full-document method (Firefox documents such methods in its Python API), or implement and test a deliberate scroll-and-stitch process.
Content is missing or covered
- Cause: Lazy images, web fonts, cookie dialogs, chat widgets, animations, or asynchronous requests were still active.
- Fix: Wait for selectors and network-dependent application state, trigger lazy content as required, dismiss overlays, and freeze or wait for transitions before saving.
Headless and headed runs disagree
- Cause: Different window-management paths, scaling, fonts, GPU behavior, or browser flags.
- Fix: Keep browser and driver versions, flags, fonts, OS image, and requested dimensions identical; maintain separate baselines when environments intentionally differ.
Resolution choices for visual tests
| Goal | Recommended approach | Important qualification |
|---|---|---|
| Test a responsive breakpoint | Set the window before navigation, then verify viewport values | Outer window and CSS viewport can differ |
| Match a desktop test environment | Use a consistent headed or headless setup and record OS and driver context | Window managers can alter the effective rectangle |
| Capture what a user currently sees | Use the ordinary current-window screenshot API | Below-the-fold content is not included automatically |
| Archive an entire page | Use a documented full-page method for the selected browser, or a tested stitching workflow | A taller window alone is not full-page capture |
Or skip the browser setup
ScreenshotNeo provides a website screenshot API when you need an image without maintaining Selenium and a browser session. One GET request returns PNG, JPEG, WebP, or PDF. For example, with cURL:
Rank #4
- CURVED FOR ENHANCED ENGAGEMENT: An immersive viewing experience with a curved monitor that wraps more closely around your field of vision; It creates a wider view, enhancing depth perception and minimizing peripheral distraction
- SMOOTH PERFORMANCE FOR SEAMLESS CONTENT: Stay in the action when playing games, watching videos, or working on creative projects; The 100Hz refresh rate reduces lag and motion blur so you don't miss a thing in fast-paced moments¹
- MORE GAMING POWER: Gain the edge with optimizable game settings; Color and image contrast can be adjusted to see scenes more vividly and spot enemies hiding in the dark; Game Mode adjusts any game to fill the screen so you can view every detail²
- KEEP IT EASY ON THE EYES: Care for your eyes and stay comfortable, even during long sessions; Advanced eye comfort technology certified by TÜV reduces eye strain by minimizing blue light and reducing irritating screen flicker²
- INCREASED VERSATILITY: Connect to more; Plug devices straight into your monitor for increased flexibility, making your computing environment even more convenient
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
See the ScreenshotNeo documentation for request parameters and response details. Equivalent Python:
import requests
r = requests.get("https://api.screenshotneo.com/v1/shot", params={"access_key": "YOUR_API_KEY", "url": "https://stripe.com"}, timeout=90)
open("shot.webp", "wb").write(r.content)
Node.js:
const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://stripe.com' });
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);
Before capture, ScreenshotNeo accepts cookie or consent banners and removes more than 60 known consent platforms, newsletter popups, and chat widgets; each cleanup step can be disabled. Bot checks or CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed, and response headers identify the page verdict and billing result. Its MCP server exposes take_screenshot, get_page_info, and capture_pdf to Claude, Cursor, and other MCP clients.
Do these 3 things before closing this tab:
1Scan for outdated or missing drivers - takes under a minute2Clear out junk files and repair common Windows errors3Fix the driver behind crashes, sound loss and screen glitchesFor controlled captures you can set full-page mode, lazy-image loading, a CSS selector for one element, dark mode, any viewport or one of 12 device presets, retina scale, PDF paper size and margins, custom CSS or JavaScript, a pre-capture click, hidden selectors, selector/delay/network-idle waits, ad/tracker/request/resource blocking, headers, cookies, user agent, Authorization, timezone, geolocation, transparent backgrounds, resizing, a chosen cache TTL, signed public-image links, asynchronous jobs with signed webhooks, bulk capture of up to 100 URLs per call, usage data, and an OpenAPI specification. Parameter names used by other screenshot APIs also work to ease migration.
The Free plan includes 1,000 screenshots per month with no card. Paid plans start at $5 for 3,000 shots; every feature is available on every plan, and annual billing gives two months free. Create a free ScreenshotNeo account to get started.
Best Value
- 【INTEGRATED SPEAKERS】Whether you're at work or in the midst of an intense gaming session, our built-in speakers provide rich and seamless audio, all while keeping your desk clutter-free.
- 【EASY ON THE EYES】 Protect your eyes and enhance your comfort with Blue-Light Shift technology. This feature reduces harmful blue light emissions from your screen, helping to alleviate eye strain during long hours of use and promoting healthier viewing habits.
- 【WIDEN YOUR PERSPECTIVE】Our sleek minimal bezel design ensures undivided attention. The nearly bezel-free display seamlessly connects in a dual monitor arrangement, delivering an unobstructed view that lets you focus on more at once, completely distraction-free.
FAQ
Should I use set_window_size or set_window_rect?
Use set_window_size when width and height are all you need. Use set_window_rect when you also need to set or inspect the window position and your browser supports the W3C-compatible operation.
Does Selenium’s window size set device resolution?
No. It requests a browser-window rectangle. CSS viewport dimensions and bitmap pixels can still vary with browser chrome, scaling, device-pixel ratio, headless mode, and the operating system.
Can I make a screenshot deterministic by choosing a larger height?
Not by itself. Height changes the visible window; it does not guarantee full-document capture or eliminate differences caused by window management and page timing.
Frequently Asked Questions
How do I capture a single element instead of the whole window?
Locate the element with Selenium and use the binding’s element screenshot method, then verify whether the driver includes only the element bounds or applies browser-specific scaling.
What should I store with a visual-regression baseline?
Store the image plus the requested and effective sizes, browser and driver versions, operating system, headless setting, device-pixel ratio, and the test’s readiness conditions.
Quick Recap
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.
Recommended Free Tools

