ScreenshotNeo

BlogHow-to

Selenium Screenshot Zoom Is Wrong: Which Setting Should You Change?

First identify whether browser page zoom, viewport size, or screenshot pixel density is wrong. They are separate settings, and Selenium has no universal cross-browser zoom command.

By the ScreenshotNeo team4 October 20265 min read

If a Selenium screenshot looks too large or too small, first check the browser’s page zoom and return it to 100% if it was changed. If the content scale looks right but the layout or image dimensions are wrong, inspect the viewport size and device scale factor instead. These are separate controls; changing device scale is not the same as changing browser page zoom.

There is no single Selenium setting documented as a page-zoom fix for every browser. The right setting depends on the browser, driver, versions, and what looks wrong. Selenium’s screenshot methods control image capture; they do not establish a universal zoom correction. [Selenium BiDi documentation] [Selenium Chrome WebDriver API]

1. Diagnose which kind of scale is wrong

What you see Likely setting to inspect
All page content is uniformly larger or smaller than expected Browser page zoom. Check the browser’s zoom level and reset it to 100% if it was changed.
Text size seems right, but the page wraps differently or responsive layout changes Viewport width and height. In Chromium, inspect device metrics overrides.
Layout is right, but screenshot pixel dimensions or density differ Viewport dimensions and device scale factor. Do not treat device scale factor as page zoom.
Screenshot cuts off content or includes only the visible viewport Capture method: viewport screenshot versus full-document screenshot.

Record the browser and version, Selenium and driver versions, viewport dimensions, device scale factor, and expected screenshot dimensions before changing settings. Chromium protocol controls are versioned, and some emulation controls are experimental. [Chrome DevTools Protocol] [Selenium-maintained protocol definition]

2. Check browser page zoom first

  1. Reproduce the issue with the same browser and driver used for the screenshot.
  2. Inspect the browser’s current page zoom. If it is not 100%, reset it and capture again.
  3. Compare the page layout and the output image dimensions separately. If the layout changes unexpectedly, capture the viewport and device scale values too.
  4. Repeat with a clean browser profile if the zoom appears to persist between runs; this helps determine whether the state comes from the profile or the page.

This is a troubleshooting sequence, not a cross-browser Selenium zoom API. Avoid assuming that a browser preference or capability used for one driver applies to another.

3. Check viewport and device scale in Chromium

Chromium’s Emulation.setDeviceMetricsOverride controls screen and viewport-related metrics, including width, height, and device scale factor. It is useful when the viewport or output density is wrong. It does not mean “set browser page zoom.” The protocol also lists a separate scale value for the resulting view, so keep the intended control clear. [Protocol definition]

For example, this Python snippet applies a Chromium device metrics override before taking a viewport screenshot. Use it only when those metrics are the issue; it does not reset page zoom.

from pathlib import Path
from selenium import webdriver

options = webdriver.ChromeOptions()
driver = webdriver.Chrome(options=options)
try:
    driver.set_window_size(1440, 1000)
    driver.get("https://example.com")

    # Chromium-specific: viewport/device metrics, not browser page zoom.
    driver.execute_cdp_cmd("Emulation.setDeviceMetricsOverride", {
        "width": 1440,
        "height": 1000,
        "deviceScaleFactor": 1,
        "mobile": False,
    })
    driver.save_screenshot("screenshot.png")
finally:
    driver.quit()

Choose dimensions and scale factor that match the target you are reproducing. Do not copy these sample values as a universal default. If you need the entire document rather than the visible viewport, use a browser-supported full-document capture method; Firefox’s Selenium API documents full-document screenshots, but that method itself does not control page zoom. [Selenium Firefox WebDriver API]

4. Choose the right capture method

  • Viewport capture: captures the visible browser area. Check viewport width and height when responsive layout or cropping is wrong.
  • Full-document capture: captures beyond the visible area where the browser API supports it. This changes the capture extent, not page zoom.
  • Device emulation: adjusts metrics such as viewport dimensions and device scale in Chromium. It can change responsive behavior or screenshot density, so record the values with the output.

Selenium’s WebDriver BiDi is a bidirectional protocol developed with browser vendors and described by Selenium as a cross-browser direction for capabilities provided by CDP. Selenium’s documentation also says its current functionality is limited. Do not infer that BiDi provides one page-zoom command supported uniformly by all browsers. [Selenium BiDi documentation]

5. Troubleshooting

Symptom Likely cause What to do
Everything appears scaled, including text and images Browser page zoom differs from the expected state Inspect browser zoom and reset it to 100% if it was changed; capture again.
Responsive breakpoints or line wrapping differ Viewport width or height differs Set and record the intended window or viewport dimensions. For Chromium, inspect device metrics overrides.
Screenshot has unexpected pixel density Device scale factor differs from the target Check deviceScaleFactor separately from page zoom. Confirm the expected image pixel dimensions.
CDP command fails or behaves differently after an upgrade Browser and protocol versions may not match the assumptions in the command Record browser and driver versions, consult the protocol definition for that version, and verify whether the control is experimental.
Firefox or another non-Chromium browser ignores a CDP snippet CDP is Chromium-specific Use that browser’s driver and supported configuration. No shared page-zoom command is established by the cited Selenium documentation.
Page is correct but screenshot is truncated Viewport screenshot used where full-document capture was needed Use a supported full-document capture method and check its browser-specific behavior.
Old Internet Explorer guidance mentions ignoreZoomSetting Legacy IE-specific capability Do not treat it as a modern cross-browser Selenium fix. The historical reference concerned skipping IE’s browser zoom check. [Historical Selenium IE driver documentation]

6. Reliability, performance, and cost notes

Keep the browser, driver, viewport, and scale configuration fixed when comparing captures. Browser and protocol changes can alter available emulation behavior, and experimental controls can change. A screenshot that differs in pixel dimensions may still have the intended page layout; compare both the rendered content and the image dimensions.

Device emulation is useful for reproducing a target viewport, but it changes the rendering environment. For reliable comparisons, record the browser and driver versions, viewport width and height, device scale factor, capture method, and page zoom state alongside each image. No benchmark or universal performance cost is established by the cited sources.

Or skip the browser setup

ScreenshotNeo is a website screenshot API and MCP server. Make one request for an image or PDF; see the ScreenshotNeo API documentation for options.

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://example.com -o shot.webp
import requests

r = requests.get(
    "https://api.screenshotneo.com/v1/shot",
    params={"access_key": "YOUR_API_KEY", "url": "https://example.com"},
    timeout=90,
)
open("shot.webp", "wb").write(r.content)
const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://example.com' });
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);

Cookie banners are accepted and removed before capture, along with supported newsletter popups and chat widgets. Bot checks, blank pages, failed loads, timeouts, and cache hits are not billed. An MCP server gives AI agents tools to take screenshots. The free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000. Sign up for 1,000 free screenshots a month, with no card.

FAQ

Should I change deviceScaleFactor to fix browser zoom?

No. It controls device scale in Chromium emulation; it is not the browser’s ordinary page zoom setting.

Does Selenium have one zoom command for Chrome and Firefox?

The cited Selenium documentation does not establish a universal cross-browser page-zoom command. Check the browser and driver in use.

Can a full-page screenshot fix incorrect zoom?

No. Full-document capture changes how much of the page is captured. It does not itself correct page zoom or device metrics.