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.

Set deviceScaleFactor when you create a Playwright browser context, then set fullPage: true in the screenshot call. These are separate controls: the context setting emulates device pixel ratio (DPR), while screenshot scale determines whether the output bitmap uses CSS pixels or device pixels. Set both explicitly when exact output dimensions matter.

Capture a full page at device scale factor 2

This JavaScript/TypeScript example sets a 1280 × 1024 CSS-pixel viewport, emulates DPR 2, and requests a full-page PNG at device-pixel scale:

const context = await browser.newContext({
  viewport: { width: 1280, height: 1024 },
  deviceScaleFactor: 2,
});
const page = await context.newPage();
await page.goto('https://example.com');
await page.screenshot({
  path: 'full-page.png',
  fullPage: true,
  scale: 'device',
});

Use a browser instance named browser that your script has already launched. The viewport dimensions describe the CSS layout area; the screenshot’s full-page height follows the rendered document and is not set by the viewport height alone.

Understand DPR, screenshot scale, and dimensions

deviceScaleFactor configures the context

Set deviceScaleFactor in browser.newContext(), not in page.screenshot(). It emulates the device pixel ratio for the browser context, and its documented default is 1. Configure the viewport separately; Playwright’s emulation guide demonstrates both settings together. Playwright Browser.newContext API · Playwright emulation guide

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

scale controls the bitmap mapping

  • scale: 'css' produces one bitmap pixel per CSS pixel, which is useful for compact output whose dimensions track CSS layout dimensions.
  • scale: 'device' produces one bitmap pixel per device pixel. With a high-DPI context, the resulting bitmap can be larger.

For a reproducible artifact, declare the viewport, device scale factor, and screenshot scale rather than relying on defaults. Playwright Page.screenshot API

Choose the right options for your task

Setting or API Choose it when Effect
scale: 'css' You want compact output measured in CSS pixels One bitmap pixel per CSS pixel
scale: 'device' You want device-pixel detail or high-DPI output One bitmap pixel per device pixel; a high-DPI configuration can produce a larger bitmap
page.screenshot() You want to capture a screenshot file Its documented default scale is device
Playwright Test screenshot assertion You want screenshot output as part of a test assertion Its documented default scale is css

The screenshot API and Playwright Test assertion API do not share the same documented default. Specify scale explicitly when output dimensions matter. Page.screenshot API · Playwright Test screenshot assertion options

Configure the same settings in Playwright Test

Set the project’s context options in playwright.config.ts, then pass the desired full-page and scale options to the screenshot call in your test:

import { defineConfig } from '@playwright/test';

export default defineConfig({
  use: {
    viewport: { width: 1280, height: 1024 },
    deviceScaleFactor: 2,
  },
});
await page.screenshot({
  path: 'full-page.png',
  fullPage: true,
  scale: 'device',
});

If you start from a device descriptor, explicit viewport values can override the descriptor’s viewport settings. Keep the intended viewport and device scale factor together in the project configuration. Playwright emulation guide

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

Python syntax

Python uses snake_case for these options. Set the scale factor when creating the context and use full_page=True for the capture:

browser = await playwright.chromium.launch()
context = await browser.new_context(
    viewport={"width": 1280, "height": 1024},
    device_scale_factor=2,
)
page = await context.new_page()
await page.goto("https://example.com")
await page.screenshot(
    path="full-page.png",
    full_page=True,
    scale="device",
)

As in JavaScript, context emulation and screenshot output scaling are distinct decisions. Playwright Python Page.screenshot API

Troubleshoot unexpected screenshot dimensions

The screenshot is larger than expected

Check whether the context uses a device scale factor greater than 1 and whether the screenshot call uses scale: 'device'. To produce one bitmap pixel per CSS pixel, use scale: 'css'. The result’s full-page height also depends on the rendered document, not just the configured viewport.

The screenshot seems to ignore the device scale factor

Verify that deviceScaleFactor was set when creating the browser context. It is not a page.screenshot() option. Also check that you are capturing with the same context that received the setting.

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

Test screenshots and page screenshots differ in size

Set scale explicitly. The documented default is device for Page.screenshot but css for Playwright Test screenshot assertions.

Full-page output misses content or changes between runs

fullPage: true requests the whole scrollable page, but identical behavior is not established for every browser engine or for pages that change or load lazy content during capture. Validate the result in the browser and on the page you actually target; do not assume every lazy-loading or dynamic page will render identically.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Or skip the browser setup

ScreenshotNeo is a website screenshot API and MCP server. Its one-call API can return a clean screenshot or PDF; cookie/consent banners, newsletter popups, and chat widgets are removed before the shot. Bot checks, blank pages, and failed loads are never billed. Its MCP server lets AI agents take screenshots, and 1,000 screenshots a month are free with no card; paid plans start at $5 for 3,000.

Example cURL request (adapt the target URL as needed):

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
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 details. Sign up for 1,000 free screenshots a month with no card.

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.