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

Set the browser window size before you capture: in Python, call driver.set_window_size(width, height), then save the screenshot. For example, requesting 1920 × 1080 sets the WebDriver window dimensions; it does not guarantee that every browser and operating system will write a PNG with exactly 1920 × 1080 physical pixels. If exact file dimensions matter, measure the image produced by the same browser and runtime you use in deployment.

What “screenshot resolution” means in Selenium

The phrase can refer to two different things: the dimensions Selenium requests for the browser window, or the dimensions, in physical pixels, of the resulting image file. Selenium gives you a direct control for the first: set the current window’s width and height in pixels. A screenshot method then captures the current window.

Those two measurements are related, but they are not an unconditional promise of a one-to-one result. Operating system display scaling, headless configuration, browser zoom, and device-pixel ratio can affect the PNG dimensions. The Selenium API does not establish that every combination produces an image whose physical pixel dimensions exactly equal the requested window size. Treat the requested size as your input, and inspect the actual image in the target environment when exact output dimensions are a requirement.

There is also a capture-scope distinction: a current-window screenshot is not automatically a full-document screenshot. Choose based on whether you need the visible browser view or the entire page.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Sale
Philips 24 Inch Computer Monitor FHD 100Hz VA VESA Flicker-Free, 241V8LB
  • 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

Set the window size in Python

Use set_window_size(width, height) before navigation or capture when you need a consistent requested viewport. The width and height arguments are in pixels. Selenium documents the method as setting the current window’s width and height, and gives driver.set_window_size(800, 600) as an example.

from selenium import webdriver

 driver = webdriver.Chrome()
 driver.set_window_size(1920, 1080)
 driver.get("https://example.com")
 driver.save_screenshot("/absolute/path/screenshot.png")
 driver.quit()

In production code, put cleanup in a finally block so the browser is closed even if navigation or screenshot writing raises an error:

from selenium import webdriver

 driver = webdriver.Chrome()
 try:
     driver.set_window_size(1920, 1080)
     driver.get("https://example.com")
     saved = driver.save_screenshot("/absolute/path/screenshot.png")
     if not saved:
         raise RuntimeError("Selenium did not save the screenshot")
 finally:
     driver.quit()

The example requests a 1920-by-1080 browser window and saves the current-window capture as a PNG. Use a full, valid path and a .png filename; Selenium’s screenshot method writes PNG output. The Boolean result of save_screenshot can be checked so a failed save is not silently treated as success.

Change the requested dimensions

Replace 1920 and 1080 with the width and height your test requires. For example, a requested 800-by-600 window is written as driver.set_window_size(800, 600). Set the size before loading the page if the page should lay itself out at those dimensions from the start; set it before capture at minimum.

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

Use the window rectangle API

For W3C-compatible browsers, set_window_rect is the equivalent size-and-position method. You can specify just the dimensions when position is irrelevant:

Rank #2
Philips 22 Inch Computer Monitor FHD 100Hz VA VESA Flicker-Free, 221V8LB
  • 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
driver.set_window_rect(width=1920, height=1080)

The rectangle API can also set window position, but for resolution control alone there is no need to provide one. Both sizing methods concern the browser window; neither removes the need to check the produced image if exact physical dimensions matter.

Save a file or keep screenshot data in memory

Use save_screenshot(filename) when the next step expects a PNG file. If you need image data in the program instead, Selenium provides two alternatives:

  • driver.get_screenshot_as_png() returns PNG bytes.
  • driver.get_screenshot_as_base64() returns base64-encoded text.

These methods change how you receive the capture, not how you request the window dimensions. Set the size first, then call the output method that fits your workflow. The bytes form is suitable when code will handle binary image data; the base64 form is useful when the receiving interface expects encoded text.

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

Choose the right capture scope

Current-window screenshot

save_screenshot is documented as saving a screenshot of the current window to a PNG image file. Use it when the deliverable should represent the current browser view. Resizing the window sets the requested size of that view, subject to the runtime caveat above.

Full-document screenshot

If you need the entire page rather than the current window, confirm that the browser binding and capture method you use support full-document screenshots. Firefox’s WebDriver API documents full-document screenshot support; that is distinct from merely setting the window size. Do not assume that changing the window dimensions alone changes a viewport capture into a full-page capture.

Rank #3
Sale
Dell 24 Monitor - SE2426H - 23.8-inch FHD (1920x1080) 144Hz 1ms Display, in-Plane Switching (IPS) Technology, AMD FreeSync™, TÜV 3-Star 2X HDMI, Tilt
  • 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.

Java and JavaScript equivalents

The same WebDriver concept is available in other language bindings. The calls below show the sizing and capture operations; file handling and return types are binding-specific, so adapt the capture line to the API version used by your project.

Java

import org.openqa.selenium.Dimension;
import org.openqa.selenium.OutputType;
import org.openqa.selenium.TakesScreenshot;

// Set the requested browser window dimensions.
driver.manage().window().setSize(new Dimension(1920, 1080));

// Retrieve the screenshot as a file.
((TakesScreenshot) driver).getScreenshotAs(OutputType.FILE);

The example obtains a screenshot file but does not move or rename it. Use the file-handling code appropriate to your application to place it at the desired destination.

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

JavaScript

await driver.manage().window().setRect({ width: 1920, height: 1080 });
const screenshot = await driver.takeScreenshot();

Here, setRect requests the window dimensions, and takeScreenshot returns the screenshot through the JavaScript binding. Consult that binding’s API for the exact representation and how to write it to a file.

Verify the PNG when dimensions must be exact

Do not infer the final PNG dimensions solely from the values passed to set_window_size. Check the image created by the same browser, operating system, and headless or headed configuration used for the real run. This matters when an image is being compared against a fixed-size reference, passed to a downstream service with strict dimensions, or used as a deliverable with an explicit pixel-size requirement.

  1. Set the requested window dimensions before navigating or capturing.
  2. Save a screenshot from the target runtime using the same method and configuration as the actual job.
  3. Inspect the saved PNG’s width and height with the image inspection tool already used in your workflow.
  4. If the dimensions differ from the requirement, adjust the runtime or capture setup and verify again; do not assume a single requested window size behaves identically across environments.

This is an implementation check, not evidence that one particular scale factor or adjustment will work everywhere. The Selenium API describes the window-size control, while the output dimensions still need verification in the environment that matters.

Rank #4
Samsung 27" Essential S3 (S36GD) Series FHD 1800R Curved Computer Monitor
  • 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
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Troubleshooting the wrong screenshot size

The PNG dimensions do not match the requested width and height

First distinguish a mismatch in the requested browser window from a mismatch in the saved image’s physical pixel dimensions. The API call controls the former. Check the resulting file in the target environment, and account for operating system display scale, headless configuration, browser zoom, and device-pixel ratio. The cited Selenium API does not guarantee identical physical output dimensions for every combination.

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

The page layout looks like the wrong size

Set the window size before navigating, then load the page again and capture it. This lets the page load at the requested window dimensions rather than relying on a later resize. If the result still differs, verify that the code sets the size on the same driver instance that navigates and captures the page.

The screenshot is missing or not where expected

Use an absolute destination path, make sure the directory exists and is writable, and use a PNG filename such as /absolute/path/screenshot.png. Check the return value of save_screenshot; if it reports failure, handle that as an unsuccessful capture rather than continuing as if the file were ready.

The screenshot shows only part of a long page

A current-window capture and a full-document capture are different requirements. Use a method and browser binding that supports full-document screenshots when that is the intended output. Firefox’s WebDriver API documents that capability; setting a larger window is not itself a guarantee that the whole document will be captured.

The sizing call is unsupported in a particular browser setup

Try set_window_rect(width=..., height=...) when the browser is W3C-compatible, or use the sizing call documented by the binding you have installed. Chromium’s and Firefox’s WebDriver APIs expose set_window_size, set_window_rect, and screenshot capture methods, but the exact behavior still depends on the target setup.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Best Value
Sale
Sceptre New 22-Inch Gaming Monitor, FHD 1080p, Up to 144Hz, HDMI, DisplayPort, Built-in Speakers, Machine Black (E225W-FW144 Series, 2026)
  • 【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.

Or skip the browser setup

If you need an image or PDF from a URL without managing a Selenium browser session, ScreenshotNeo provides a website screenshot API and MCP server for developers. A single GET request can return a PNG, JPEG, WebP, or PDF. Its clean-shot steps accept consent banners and remove more than 60 known consent platforms, newsletter popups, and chat widgets before capture; each step can be turned off. Bot checks, blank pages, timeouts, failed loads, and cache hits cost nothing, and responses identify the page verdict and billing status in headers. AI agents can use the MCP server tools take_screenshot, get_page_info, and capture_pdf.

For example, this cURL request captures a URL and saves the result as a WebP file:

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 API documentation for request options and authentication details. The free plan includes 1,000 shots per month with no card; paid plans start at $5 for 3,000 shots. Sign up for 1,000 free screenshots a month with no card.

Frequently Asked Questions

Does set_window_size set a physical monitor resolution?

No. It sets the current WebDriver window’s requested width and height; physical display resolution is a separate matter.

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

Can I request a screenshot without saving a PNG file?

Yes. Selenium provides screenshot output as PNG bytes or base64 text through its in-memory methods.

Does 1920 × 1080 guarantee a 1920 × 1080 screenshot?

No. Verify the resulting file in the browser and runtime where exact physical pixel dimensions matter.

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.