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

Set Chromium’s visible page dimensions through Playwright’s viewport context option or test configuration; to resize a page that already exists, use page.setViewportSize(). Keep viewport dimensions separate from device scale factor, screenshot output scale, and full-page capture: they control different things.

Set the viewport when creating a Playwright context

Choose dimensions that match the responsive layout or device scenario you want to capture. This example creates a context with a 1280 × 1024 CSS-pixel viewport, opens a page, and saves a screenshot of the visible viewport:

const context = await browser.newContext({
  viewport: { width: 1280, height: 1024 },
});
const page = await context.newPage();
await page.goto('https://example.com');
await page.screenshot({ path: 'page.png' });

Set the viewport before navigating when you want the page to load and lay itself out at those dimensions. The values above are an example, not a universally correct screenshot size. Playwright documents context-level viewport configuration in its Emulation guide.

Set a viewport in Playwright Test configuration

For repeatable test runs, put the dimensions in the Chromium project’s use settings. When using a device preset, spread it first so your explicit viewport overrides the preset’s viewport:

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
import { defineConfig, devices } from '@playwright/test';

export default defineConfig({
  projects: [
    {
      name: 'chromium',
      use: {
        ...devices['Desktop Chrome'],
        viewport: { width: 1280, height: 720 },
      },
    },
  ],
});

Here, the configured viewport is 1280 × 720 CSS pixels. The preset can supply other device settings, but the explicit viewport value takes precedence because it appears after the spread. Playwright describes this override pattern in its Emulation documentation.

Resize an existing page

If a page is already open, change its viewport with page.setViewportSize():

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
await page.setViewportSize({ width: 1600, height: 1200 });

This changes the page’s emulated visible area and can trigger a responsive layout change. Use it when a test needs to exercise more than one viewport without creating a new context.

Understand viewport, pixel density, screenshot scale, and capture scope

These settings are related but not interchangeable. A viewport describes the emulated visible area in CSS pixels; the screenshot scale determines how CSS pixels map to output image pixels.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
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.
Setting What it controls Example or effect
viewport Visible page width and height in CSS pixels, affecting responsive layout. { width: 1280, height: 720 }
deviceScaleFactor Emulated device pixel density. A value of 2 emulates twice as many device pixels per CSS pixel.
Screenshot scale Output mapping: css produces one image pixel per CSS pixel; device produces one image pixel per device pixel. device output can produce a larger bitmap at a higher device scale factor.
fullPage Capture scope: the viewport alone or the full scrollable page. fullPage: true captures the full page rather than only the visible area.

For example, to emulate a 1280 × 720 CSS-pixel viewport at a device scale factor of 2:

const context = await browser.newContext({
  viewport: { width: 1280, height: 720 },
  deviceScaleFactor: 2,
});

Do not assume viewport dimensions alone determine the screenshot bitmap’s dimensions. The screenshot scale option also matters. Likewise, increasing viewport height is not the same as setting fullPage: true. Playwright documents screenshot scale and full-page behavior in its API parameters reference.

Rank #4
Sale
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

Choose dimensions for the layout you need to test

There is no single best viewport size for every site or screenshot. Select width and height to represent the target layout, breakpoint, or test case. If the goal is to check how a page responds at different widths, capture separate cases at the widths relevant to your design rather than treating one preset as universally representative.

Use Chrome DevTools Protocol for lower-level control

If you are working directly with the Chrome DevTools Protocol (CDP), Emulation.setDeviceMetricsOverride controls emulated device dimensions, device scale factor, and mobile emulation. Screenshot capture is documented in the CDP Page domain. You need a debugging session attached to the relevant Chromium target, and protocol details can evolve, so check the schema for the Chromium build you run. When your project already uses Playwright, its context and page APIs are usually the more direct option. See the CDP Page protocol reference and the Playwright Emulation guide.

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.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Troubleshoot viewport and screenshot mismatches

  • The page keeps using the preset’s dimensions: In Playwright Test, put viewport after the device preset spread in use, so your explicit width and height override the preset.
  • The layout is right but the image dimensions are unexpected: Check both deviceScaleFactor and screenshot scale. They are separate from the viewport.
  • The screenshot stops at the visible area: That is the normal viewport capture. Set fullPage: true if you need the full scrollable page.
  • The layout does not match the intended scenario: Confirm the viewport width and height represent the target breakpoint or device scenario; there is no universally correct size.
  • A direct CDP command does not take effect: Confirm the debugging session is attached to the intended target and consult the protocol schema matching your Chromium build.

Or skip the browser setup

ScreenshotNeo takes a screenshot through one GET request, without configuring a Chromium context yourself. Its clean-shot flow accepts cookie or consent banners like a visitor and removes 60+ known consent platforms, newsletter popups, and chat widgets before capture; each step can be turned off. Bot checks and CAPTCHAs, blank pages, timeouts, failed loads, and cache hits cost nothing, and responses report the page verdict and billing status in headers. ScreenshotNeo also offers an MCP server with screenshot tools for AI agents.

Example cURL request:

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, including viewport controls. The free plan includes 1,000 screenshots a month with no card; paid plans start at $5 for 3,000. Learn about ScreenshotNeo or sign up for 1,000 free screenshots a month with no card.

Frequently Asked Questions

Does setting a viewport guarantee the same screenshot bitmap dimensions?

No. The screenshot scale option and device scale factor also affect the mapping from CSS pixels to output pixels.

Which Playwright viewport size should I use?

Use dimensions that represent the layout, responsive breakpoint, or device scenario you need to test; no single size is right for every page.

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.

Does a taller viewport capture the entire page?

No. To capture the full scrollable page, use the screenshot option fullPage: true.

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.