The Tool Desk
Outbyte Driver Updater FREEFix the driver behind crashes, sound loss and screen glitchesFind Drivers →Outbyte PC Repair FREERepair Windows errors before they cause bigger problemsFix Now →If a Playwright screenshot has the wrong dimensions, check three separate settings: the page’s viewport in CSS pixels, the browser context’s deviceScaleFactor, and the screenshot’s scale. Set the viewport before navigation, choose the output scale explicitly, and use fullPage only when you want the whole scrollable document. These settings control layout size, pixel density, and capture area respectively—not the same thing.
Why a Playwright screenshot has the wrong size
A screenshot’s dimensions can differ from what you expect because Playwright separates the page’s layout viewport from its raster density and the region being captured. A viewport of 1280 × 720 means 1280 × 720 CSS pixels; it does not mean the browser window or monitor has those physical-pixel dimensions.
As an Amazon Associate I earn from qualifying purchases.
| Setting | What it controls | Where to set it |
|---|---|---|
| Viewport | Page layout width and height in CSS pixels | Browser context, Playwright Test configuration, or page.setViewportSize() |
deviceScaleFactor |
Device pixel ratio (DPR), which affects device-pixel output | Browser context |
Screenshot scale |
Whether output pixels correspond to CSS pixels or device pixels | page.screenshot() |
fullPage or clip |
Which part of the page is captured | page.screenshot() |
For a fixed-size image, make all three decisions intentionally: specify the viewport, set the DPR, and select scale. Playwright documents a default deviceScaleFactor of 1, but relying on defaults for the screenshot scale can make the output ambiguous; set it explicitly. See the Page API and BrowserType API.
Do these 3 things before closing this tab:
1Repair Windows errors before they cause bigger problems2Scan for outdated or missing drivers - takes under a minute3Clear out junk files and repair common Windows errorsSet a precise viewport and screenshot size
This JavaScript example requests a 1280 × 720 CSS-pixel viewport, DPR 1, and one output pixel per CSS pixel. It writes a screenshot to page.png:
#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
const { chromium } = require('playwright');
(async () => {
const browser = await chromium.launch();
const context = await browser.newContext({
viewport: { width: 1280, height: 720 },
deviceScaleFactor: 1,
});
const page = await context.newPage();
await page.goto('https://example.com');
await page.screenshot({ path: 'page.png', scale: 'css' });
await browser.close();
})();
The intended result is a 1280 × 720 CSS-pixel capture. The code illustrates configuration; actual rendered content and dimensions can also depend on capture options and the page. Playwright’s scale: 'css' makes each CSS pixel correspond to one output pixel. With scale: 'device', each device pixel becomes an output pixel, so a higher DPR produces a larger image. The exact result depends on the DPR. Details are in the screenshot API reference.
Set the viewport before navigation
Prefer setting viewport when creating the browser context, as in the example, so the page loads at its intended layout size. You can also call page.setViewportSize({ width: 1280, height: 720 }), but do so before navigating where possible. Playwright’s API notes that some sites do not expect a phone-sized viewport to change after the page has loaded. See setViewportSize.
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
Use the intended screenshot scale
- Choose
scale: 'css'when you want one output pixel per CSS pixel. - Choose
scale: 'device'when the image should reflect device-pixel density; output dimensions can be larger than the CSS viewport at DPRs above 1.
Do not change viewport width or height to compensate for an unintended device-pixel scale. That changes page layout, not just raster density.
Capture the viewport, the whole page, or a region
Screenshot dimensions also depend on the requested capture area. A normal screenshot captures the visible viewport. Set fullPage: true to capture the full scrollable document; the resulting image can be taller than the viewport. Use clip when you want a specific rectangular region. Neither option changes pixel density: fullPage changes the capture extent, while scale controls CSS-pixel versus device-pixel output. These options are documented in the Page API.
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.
// Full scrollable page
await page.screenshot({ path: 'full-page.png', fullPage: true, scale: 'css' });
// A specific region (coordinates and dimensions are in CSS pixels)
await page.screenshot({
path: 'region.png',
clip: { x: 0, y: 0, width: 640, height: 360 },
scale: 'css',
});
Use one capture-extent choice that matches the desired result: viewport only, full page, or a clipped region.
Set the viewport in Playwright Test
In Playwright Test, set the viewport in the project’s use configuration. If spreading a device preset, put your explicit viewport after the spread so it overrides the preset’s value:
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
import { defineConfig, devices } from '@playwright/test';
export default defineConfig({
use: {
...devices['Desktop Chrome'],
viewport: { width: 1280, height: 720 },
},
});
A device preset supplies settings, including a viewport; the explicit value following the spread takes precedence. Playwright shows this ordering in its emulation guide. If DPR matters to your screenshot, configure it explicitly in the test project’s use options as well, rather than assuming a preset or default matches your target.
Debug the dimensions in this order
- Check the viewport. Confirm the active context or test project has the intended CSS-pixel width and height. Look for a later configuration or device preset that replaces them.
- Check device scale factor. Verify the context’s
deviceScaleFactorif you expect device-pixel output. The documented default is 1; set the value explicitly for a predictable setup. - Check screenshot scale. Use
'css'for one output pixel per CSS pixel or'device'for device-pixel output. - Check capture extent. Confirm whether
fullPageorclipis changing the captured area. - Check the rendering environment. For visual comparisons, align browser version and host environment between baseline generation and comparison.
Common causes and fixes
| Symptom | Likely cause | Fix |
|---|---|---|
| Image is larger than the viewport dimensions you specified | scale: 'device' with a DPR above 1 |
Use scale: 'css' for CSS-pixel output, or keep device scale and account for the DPR. |
| Page layout is wider, narrower, or reflowed unexpectedly | Wrong viewport, or a device preset overriding the intended viewport | Set the explicit viewport on the context or after the preset spread; do so before navigation where possible. |
| Image is taller than expected | fullPage: true captures scrollable content beyond the visible viewport |
Remove fullPage for a viewport capture or use a suitable clip. |
| Only part of the expected area appears | A clip rectangle constrains the capture |
Adjust or remove the clip rectangle. |
| Layout changes after resizing | The page was navigated before the viewport was set; some sites do not expect a late size change | Set the context viewport before creating or navigating the page. |
| Visual tests differ between machines despite matching dimensions | Rendering can vary with operating system, browser version, settings, hardware, power source, or headless mode | Generate and compare baselines in aligned environments and keep browser versions consistent. |
Make visual screenshot tests more reproducible
Playwright Test’s toHaveScreenshot() waits until two consecutive page screenshots produce the same result before comparing against the expectation. That helps avoid comparing against a transient capture, but it cannot eliminate differences caused by the operating system, browser version, settings, hardware, power conditions, or headless mode. Keep baseline creation and comparison environments aligned where possible. See Visual comparisons and the PageAssertions API.
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.
Or skip the browser setup
If you need an image or PDF from a URL without managing Playwright contexts, ScreenshotNeo provides a screenshot API and MCP server. A single GET request can return PNG, JPEG, WebP, or PDF. For example, this cURL request saves a WebP screenshot:
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. ScreenshotNeo removes cookie banners, newsletter popups, and chat widgets before capture; each step can be turned off. Bot checks/CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed, and responses identify the page verdict and billing status. Its MCP server offers take_screenshot, get_page_info, and capture_pdf for AI agents and MCP clients. The Free plan includes 1,000 shots per month with no card; paid plans start at $5 for 3,000 shots.
Sign up for ScreenshotNeo’s free plan: 1,000 screenshots a month, no card required.
PC Slower Than It Used to Be?
A free scan shows the junk files, broken settings and background clutter dragging Windows down - then fixes them in one click.Free scan · Windows 10 & 11Crashes, No Sound, or Screen Glitches?
Random freezes, missing sound and display glitches usually trace back to one bad driver. Find and replace yours safely.Free scan · under a minuteFrequently Asked Questions
Does fullPage: true increase screenshot resolution?
No. It expands the captured area to include scrollable page content; the screenshot’s scale determines CSS-pixel or device-pixel output.
Should I use scale: 'css' or scale: 'device'?
Use 'css' when output pixels should match CSS pixels. Use 'device' when you intend device-pixel output and want dimensions to reflect the configured DPR.
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.




