Set the browser window size in Selenium, then read it back from the live session before saving the screenshot. For Chrome headless runs, pass --window-size=1440,900 through ChromeOptions; for a headed browser that needs a Linux display, configure Jenkins Xvfb separately. These settings control different things, so verify both where applicable.
Choose the resolution you need
There is no universal Selenium screenshot resolution. Match the browser window dimensions to the viewport or visual-test baseline your application is expected to render at. Selenium notes that screen resolution can affect application rendering and documents browser-window resizing at its window documentation.
As an Amazon Associate I earn from qualifying purchases.
Use the WebDriver window size for the browser session. If you run a headed browser on a Linux Jenkins agent with a virtual display, also set the Xvfb display dimensions. The browser window and Xvfb framebuffer are separate controls.
Set and verify Chrome’s browser window size
Pass the size when Chrome starts, set it explicitly after creating the session, and query the live dimensions before capturing. This Python example combines ChromeDriver’s ChromeOptions argument pattern with Selenium’s window and screenshot APIs; it is an implementation pattern, not a claim of a test run.
#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
from selenium import webdriver
options = webdriver.ChromeOptions()
options.add_argument("--headless")
options.add_argument("--window-size=1440,900")
driver = webdriver.Chrome(options=options)
try:
# Set the target explicitly after the session starts, then verify it.
driver.set_window_size(1440, 900)
actual = driver.get_window_size()
print(f"Browser window: {actual['width']}x{actual['height']}")
driver.get("https://example.com")
saved = driver.save_screenshot("artifacts/page.png")
if not saved:
raise RuntimeError("Selenium could not write artifacts/page.png")
finally:
driver.quit()
ChromeDriver documents passing command-line arguments through ChromeOptions, including a window-size example, in its capabilities documentation. Selenium documents set_window_size(width, height), get_window_size(), and screenshot methods in its Python WebDriver API. Argument behavior can depend on browser version and run mode; the live-session check tells you what the current session reports.
Use the dimensions that match your test
Replace 1440 by 900 with the dimensions used by your visual baseline or required test viewport. Keep those values explicit and consistent across local and CI runs. A window-size setting is not a promise of pixel-identical output across different VM images or browser releases.
Rank #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
Know what Selenium’s screenshot call captures
save_screenshot() saves a screenshot of the current browser window. Do not assume it means a full-page capture. If the baseline represents only the visible viewport, this is often the relevant capture; if it represents a larger page region, confirm that your capture method and test expectation match.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
Configure Xvfb when Jenkins needs a virtual display
For a headed browser on a Linux agent that requires a display server, the Jenkins Xvfb plugin can wrap the build with a virtual framebuffer. Its screen setting uses WxHxD: width, height, and color depth. For example, 1440x900x24 requests a 1440-by-900 display with 24-bit color depth.
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.
wrap([$class: 'Xvfb', screen: '1440x900x24']) {
sh 'pytest'
}
Use the plugin’s documented Pipeline step and ensure Xvfb is configured on the Jenkins node. See the Jenkins Xvfb plugin documentation for configuration details. The plugin notes that explicit display names can conflict; use automatic display assignment where supported if concurrent jobs might contend for a display.
Set the WebDriver window size as well as Xvfb’s screen size. The Xvfb value defines the virtual display, while Selenium’s window-size APIs define and report the browser window. Setting one does not substitute for the other.
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
Keep screenshots accessible as Jenkins artifacts
Save screenshots into a directory in the job workspace, such as artifacts/page.png, and configure the job to retain that path as an artifact if you need to inspect it after the build. Selenium’s screenshot-to-file method reports whether writing succeeded; the sample checks that result. A successful file write alone does not confirm that the image has the expected dimensions, so inspect the captured artifact when diagnosing visual differences.
Recommended Free Tools
Troubleshoot resolution and screenshot mismatches
- Reported size differs from the requested size: Query
driver.get_window_size()after the browser starts. Set the window size through WebDriver, inspect the returned values, and check that the Chrome startup argument is being passed to the intended session. - A headed browser fails to start on the Jenkins VM: If the agent needs a display, run the build inside the Xvfb wrapper and confirm the node has the Xvfb installation configured. Set a screen size large enough for the browser window.
- The browser window fits locally but not in CI: Compare the live WebDriver dimensions and, for headed runs, the Xvfb dimensions. Keep the browser mode and version consistent where possible; the cited documentation does not establish a recipe for pixel-identical rendering across VM images or browser releases.
- The image is smaller than the full page: Selenium’s current-window screenshot is not synonymous with a full-page capture. Check whether the test baseline is for the visible window or a larger page region.
- No screenshot appears after the job: Check the return value from
save_screenshot(), confirm the destination directory exists and is writable, and retain the workspace path as a Jenkins artifact. - Concurrent builds conflict over a display: Avoid reusing an explicit Xvfb display name where jobs may overlap; use automatic display assignment if the plugin setup supports it.
Or skip the browser setup
If you need an image from a URL rather than a Selenium test session, ScreenshotNeo can return a screenshot or PDF with one GET request. Its cookie/consent-banner handling and removal of known newsletter popups and chat widgets can be turned off. Bot checks, blank pages, failed loads, timeouts, and cache hits are not billed, and responses identify the page verdict and billing status in headers. Its MCP server provides screenshot tools for AI agents.
For example, save a WebP capture of a target URL with cURL:
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.
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://example.com -o shot.webp
See the ScreenshotNeo API documentation for request options. The free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000. Sign up for free to try it.
Frequently Asked Questions
Does Xvfb set the Selenium browser window size?
No. Xvfb configures the virtual display; set and verify the browser window separately through WebDriver.
Does Selenium’s window screenshot automatically capture the whole page?
No. It captures the current browser window; a full-page image is a different capture requirement.
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.




