Hardware FixRecommendedDevice not working? Your driver may be the problemCheck updates for common hardware issues.Fix DriversOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsWindows FixRecommendedWindows errors stealing your time? Find the fix fastScan stability, cleanup and performance issues.Fix Now×
Skip to content
World desk4 min

How to Set the Viewport Size for Chromium Screenshots with Playwright

Set Chromium screenshot width and height in Playwright, then choose device scale, screenshot scale, and full-page capture separately.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Set the viewport before capturing: in Playwright, pass viewport: { width, height } when creating a browser context or in Playwright Test configuration. To resize a page that already exists, use page.setViewportSize(). Viewport dimensions control the visible CSS layout area; device scale factor, screenshot pixel scale, and full-page capture are separate settings.

Set the viewport in Playwright Test

Configure the Chromium project’s viewport in playwright.config.js or its TypeScript equivalent. When using a device preset, spread it first so the explicit viewport below overrides the preset’s viewport:

As an Amazon Associate I earn from qualifying purchases.

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

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

Choose dimensions that match the layout or responsive breakpoint you need to test. The values above are examples, not universally correct screenshot dimensions. Playwright documents context viewport configuration and page resizing in its Emulation guide.

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

Set the viewport when creating a browser context

For a standalone Playwright script, pass the viewport to browser.newContext() before creating the page. This complete example launches Chromium, navigates to a page, saves a screenshot, and closes the browser:

#1 Best Overall
Philips 24 Inch Computer Monitor FHD 100Hz VA VESA Flicker-Free, 241V8LB | 1920×1080 LED Monitor, 4ms GtG, Adaptive Sync, HDMI 1.4, Tilt Adjust, Low Blue Light, 4yr Advance Replacement Warranty
  • 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 { chromium } from 'playwright';

const browser = await chromium.launch();
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' });

await context.close();
await browser.close();

The width and height are CSS pixels. They define the emulated visible area of the page and affect responsive layout.

Resize an existing page

If the page has already been created, change its viewport with page.setViewportSize() before taking the screenshot:

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 });
await page.screenshot({ path: 'page.png' });

This resizes the visible browser area; it does not request that the screenshot include all content below the fold.

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

Keep viewport, pixel density, screenshot scale, and capture scope separate

“Resolution” can refer to several different settings. Set each one according to the result you need:

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 How to set it
Viewport The visible page dimensions in CSS pixels and the responsive layout scenario. viewport: { width, height } in a context or project, or page.setViewportSize().
Device scale factor Emulated pixel density, which is independent of viewport width and height. Set deviceScaleFactor in the browser context.
Screenshot scale Whether output pixels follow CSS pixels or device pixels. Device-pixel output can be larger for a high-DPI context. Use the screenshot scale option, 'css' or 'device'.
Capture scope Whether the screenshot covers the visible viewport or the full scrollable page. Set fullPage: true to capture the full page.

For example, to emulate a high-density display, configure device scale factor separately:

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

Then choose screenshot scale for the desired bitmap output. Playwright’s API reference explains the scale and fullPage options in its API parameters documentation. Increasing viewport height and setting fullPage: true are not interchangeable: the former changes the visible area, while the latter captures beyond it.

Rank #4
Sale
Samsung 27" Essential S3 (S36GD) Series FHD 1800R Curved Computer Monitor | 100Hz, Game Mode, Advanced Eye Comfort, HDMI and D-sub Ports (LS27D366GANXZA)
  • 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

Use Chromium’s DevTools Protocol for lower-level control

If you are controlling Chromium through the Chrome DevTools Protocol (CDP), Emulation.setDeviceMetricsOverride sets emulated device metrics, including dimensions and device scale factor. The Page domain includes screenshot capture functionality. CDP commands require a debugging session attached to the relevant target, and protocol details can change between Chromium builds. Check the schema for the Chromium version you run in the Chrome DevTools Protocol Page reference and the corresponding Emulation domain documentation. If your project already uses Playwright, its context and page APIs are usually the more direct option.

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.
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 can return a screenshot from one GET request. Set the viewport with its documented request parameters; see the ScreenshotNeo API documentation for the available options.

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.
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp

ScreenshotNeo removes cookie banners, newsletter popups, and chat widgets before capture, with each cleanup step configurable. Bot checks, blank pages, failed loads, timeouts, and cache hits are not billed; response headers report the page verdict and billing status. Its MCP server gives AI agents screenshot, page-info, and PDF-capture tools. The Free plan includes 1,000 shots per month without a card; paid plans start at $5 for 3,000 shots.

Sign up for ScreenshotNeo’s free plan to try 1,000 screenshots a month with no card.

Troubleshooting viewport screenshots

  • The page uses the wrong responsive layout: Verify that the intended width and height are set on the context or project before navigation and capture. If a device preset is involved, spread it before the explicit viewport so your values take precedence.
  • The image dimensions do not match the viewport numbers: Check deviceScaleFactor and the screenshot scale option. Viewport dimensions are CSS pixels, and screenshot scale determines whether output is based on CSS or device pixels.
  • The screenshot cuts off content: A taller viewport only changes the visible area. Use fullPage: true when you need the full scrollable page.
  • A responsive change is missing after resizing: Ensure page.setViewportSize() completes before taking the screenshot, then allow the page’s layout and any responsive scripts to update.
  • CDP metrics have no effect: Confirm that the debugging session is attached to the target you are capturing and consult the protocol schema matching your Chromium build; CDP details evolve.

Frequently Asked Questions

What viewport size should I use for a Chromium screenshot?

There is no single universally correct size. Choose the width and height for the device or responsive layout scenario you want to represent.

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

Can I set a viewport in plain Chromium without Playwright?

Yes. Chromium automation through CDP can set device metrics with Emulation.setDeviceMetricsOverride; it requires an attached debugging session.

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.

Leave a Reply

Your email address will not be published. Required fields are marked *

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

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Windows Errors? Fix Them Before They SpreadFree repair scan
Crashes, No Sound, or Screen Glitches?Free driver scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.