For a high-DPI Chrome screenshot, set the browser’s device scale factor as well as its CSS-pixel viewport, then inspect the saved image. Xvfb supplies a virtual display for a graphical browser; its screen size and DPI are not substitutes for Chrome’s device-scale setting.
What “Retina screenshot” means in a Selenium test
A Retina-style capture generally means rendering a given CSS-pixel viewport at a higher device-pixel density. For example, a 1440 × 900 CSS viewport with a device scale factor of 2 targets roughly 2880 × 1800 output pixels if the browser and screenshot path honor that emulation. Treat those dimensions as a target to verify, not a guaranteed result.
As an Amazon Associate I earn from qualifying purchases.
- Viewport size controls the page area in CSS pixels.
- Device scale factor controls the emulated ratio of device pixels to CSS pixels.
- Xvfb geometry and DPI configure the virtual X display used by a graphical browser. They do not, by themselves, establish that Chrome will save an image at twice the dimensions.
Selenium can set browser window dimensions and capture the current browsing context. Chrome’s DevTools Protocol separately exposes Emulation.setDeviceMetricsOverride with width, height, and deviceScaleFactor settings: Chrome DevTools Protocol: setDeviceMetricsOverride. Selenium’s screenshot and window controls are documented at Selenium: windows and screenshots.
Choose Xvfb or Chrome headless
Use Xvfb when the test needs a graphical browser
Xvfb provides a virtual X display for graphical applications on an unattended Linux host. Use it when the browser or test specifically needs an X display-backed graphical session. In the Selenium Docker image, the startup script reads SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_DEPTH, and SCREEN_DPI (with SE_-prefixed fallbacks) and uses them to configure xvfb-run. Those variable names describe that image’s script, not a universal Xvfb interface. See the Selenium Docker startup configuration; pin a container release or commit for repeatable CI rather than relying on a moving branch.
#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
Use headless mode when no X display is needed
Chrome headless runs without visible UI and includes screenshot options, so it may eliminate the need for Xvfb if the test does not require a graphical display. Chrome documents headless screenshots and notes Xvfb as a virtual display server for graphical applications: Chrome Headless mode. Chrome also documents configurable virtual screens and scale factors, but its examples on that page use Puppeteer; do not assume they are a Selenium recipe without checking your Chrome and Selenium versions: Chrome virtual screen configuration.
Choose the mode that matches the application behavior you need to test, then verify that device-scale emulation affects the screenshot method you use. Record the browser mode and output dimensions in CI so changes in the pinned environment are visible.
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
Set up a reproducible Selenium capture
- Pin the environment. Record Selenium, Chrome, ChromeDriver, and, when applicable, the Selenium standalone container version. Selenium’s Chrome documentation describes Selenium 4 compatibility with Chrome 75 and later on that page, but check compatibility for your actual pinned stack: Selenium: Chrome browser.
- Start a display if needed. For an Xvfb-backed session, allocate display geometry large enough for the intended browser window. In the Selenium Docker image, set its documented screen variables before startup; do not treat its DPI variable alone as a Retina switch.
- Choose CSS-pixel dimensions. Set the browser window or viewport to the dimensions the test expects. Window size and screenshot dimensions are related but are not interchangeable in every browser mode or capture path.
- Set Chrome device metrics. Apply the intended width and height with
Emulation.setDeviceMetricsOverrideand a scale factor such as2for a 2× target. The protocol documents the control; the exact Selenium binding call can vary by release, so use the binding API supported by your pinned Selenium version. - Load the page and capture. Wait for the state and assets relevant to the test, then save a screenshot with Selenium’s screenshot API.
- Validate the artifact. Check the PNG’s actual pixel dimensions and, when useful, inspect
window.devicePixelRatioandwindow.innerWidthin the page. Confirm the image matches the test’s expected rendering rather than inferring success from configuration alone.
Python example: Selenium capture with Chrome DevTools metrics
Selenium’s Python API can issue Chrome DevTools Protocol commands through execute_cdp_cmd in Selenium 4. Keep the Selenium, Chrome, and ChromeDriver versions pinned and verify this call in that environment; protocol support and screenshot behavior can change across releases.
Recommended Free Tools
from pathlib import Path
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
WIDTH = 1440
HEIGHT = 900
SCALE = 2
URL = "https://example.com"
options = Options()
# For a graphical browser under Xvfb, leave headless mode disabled.
# For a headless run, enable it and validate the resulting dimensions.
# options.add_argument("--headless=new")
driver = webdriver.Chrome(options=options)
try:
driver.set_window_size(WIDTH, HEIGHT)
driver.execute_cdp_cmd(
"Emulation.setDeviceMetricsOverride",
{
"width": WIDTH,
"height": HEIGHT,
"deviceScaleFactor": SCALE,
"mobile": False,
},
)
driver.get(URL)
# Replace this with a wait for the page content/assets your test needs.
driver.save_screenshot("retina.png")
print("viewport:", driver.execute_script(
"return [window.innerWidth, window.innerHeight, window.devicePixelRatio]"
))
finally:
driver.quit()
# Check the artifact dimensions with an image library, e.g. Pillow:
from PIL import Image
with Image.open(Path("retina.png")) as image:
print("PNG pixels:", image.size)
At 1440 × 900 and scale 2, the expected target is approximately 2880 × 1800 pixels if the chosen capture path honors the emulated metrics. The printed browser values and the image dimensions are separate checks; a mismatch means you should investigate the mode, binding, browser version, and capture path.
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.
Other Selenium bindings
The Chrome DevTools Protocol method is browser-specific. Selenium’s generic window and screenshot APIs are available across bindings, but how a binding exposes CDP commands depends on its version. Consult the official API for the pinned language binding before adapting this procedure; do not copy a CDP invocation from another binding and assume it is stable.
- Java: use the Selenium Chrome driver’s DevTools support for the pinned Selenium release, then invoke the protocol command supported by that release.
- JavaScript: use the Chrome driver’s supported DevTools interface for the pinned Selenium package.
- Other browsers: this recipe’s device-metrics command is Chrome DevTools Protocol-specific; confirm the target browser’s equivalent rather than assuming identical behavior.
Troubleshooting unexpected screenshot dimensions
The screenshot is still the CSS viewport size
Check that the DevTools metrics override ran before capture, that the command did not raise an error, and that the screenshot API and Chrome mode honor the emulated device scale. Inspect the actual PNG dimensions; changing Xvfb DPI alone is not evidence that Chrome applied a 2× scale.
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
The browser viewport is smaller or larger than expected
Window dimensions can include browser chrome in graphical mode, while a screenshot captures a browsing context. Compare window.innerWidth and window.innerHeight with the intended CSS viewport and adjust the window or emulated metrics accordingly.
Chrome fails to start in CI
If using a graphical session, confirm Xvfb is running, its display geometry is adequate, and the browser process can connect to its display. If the test does not require a graphical session, try Chrome headless instead and validate its output separately.
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.
Images or fonts are missing in the capture
Do not capture immediately after navigation if the test depends on asynchronous content. Wait for a specific element or asset condition that represents readiness for your page, then save the screenshot. A fixed delay may be useful for a known animation or transition, but it is less robust than a page-specific readiness check.
Dimensions change after an upgrade
Recheck the Selenium, Chrome, ChromeDriver, and container versions together. Headless behavior and protocol bindings can vary across releases; pinning versions and asserting the output image dimensions makes changes easier to detect.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Performance, reliability, and cost considerations
A higher device scale factor creates more output pixels, so image files and image-processing work can grow with the pixel area. A 2× scale in both dimensions targets about four times the pixels of a 1× capture at the same CSS viewport; this is arithmetic from the dimensions, not a benchmark. Use the smallest viewport and scale that meet the test’s purpose.
The Tool Desk
Outbyte PC Repair FREERepair Windows errors before they cause bigger problemsFix Now →Outbyte Driver Updater FREEScan for outdated or missing drivers - takes under a minuteDriver Scan →For reliable CI, keep the browser mode consistent with the behavior under test, pin the browser stack, wait on meaningful page readiness, and assert the saved file’s dimensions. Do not use Xvfb DPI, window size, or a successful Selenium call as a proxy for the final image’s pixel size.
Or skip the browser setup
ScreenshotNeo is a screenshot API and MCP server for developers. One GET request can return an image or PDF; its browser-side cleanup accepts cookie/consent banners and removes more than 60 known consent platforms, newsletter popups, and chat widgets before capture, with each cleanup step switchable. Bot checks, blank pages, failed loads, timeouts, and cache hits are not billed, and responses identify page verdict and billing status in headers. Its MCP server exposes screenshot and PDF tools for AI agents, and it offers 1,000 screenshots per month free without a card; paid plans start at $5 for 3,000.
Example request (replace the target URL):
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 sign up for 1,000 free screenshots a month with no card.
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.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.




