Set the viewport before navigating, then call page.screenshot(). Playwright captures the visible viewport by default; set fullPage: true only when you want the entire scrollable page.
Set a fixed viewport before loading the page
For a new page, set viewport when creating the browser context. This applies the dimensions to pages in that context before they load, so responsive layouts can render for the intended size.
As an Amazon Associate I earn from qualifying purchases.
import { chromium } from 'playwright';
const browser = await chromium.launch();
const context = await browser.newContext({
viewport: { width: 1280, height: 720 },
});
const page = await context.newPage();
try {
await page.goto('https://example.com');
await page.screenshot({ path: 'screenshot.png' });
} finally {
await browser.close();
}
The example sets a 1280-by-720 CSS-pixel viewport. Choose dimensions that match the layout you need; these are example values, not a Playwright recommendation. The viewport setting controls the browser page area, not the size of the entire screenshot file when device-scale output is used.
Choose context-level or page-level configuration
Set it for every page in a context
Use browser.newContext({ viewport: { width, height } }) when pages in that context should share the same viewport. This is the straightforward choice for a capture script or a group of pages using one viewport.
#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
Resize one page
For an existing page, call page.setViewportSize() before navigating if the site may respond to viewport size:
const page = await context.newPage();
await page.setViewportSize({ width: 1280, height: 720 });
await page.goto('https://example.com');
await page.screenshot({ path: 'screenshot.png' });
Playwright documents that page.setViewportSize() also resets the screen size. If you need more control of both screen and viewport dimensions, configure screen and viewport when creating the browser context. See the Page API and emulation guide.
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
Configure Playwright Test
Playwright’s emulation guide also documents configuring a viewport in Playwright Test configuration. For one-off capture code, context-level or page-level configuration makes the timing explicit. If you use a device descriptor, it includes a viewport that you can override.
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 errorsCapture only the viewport or the full page
page.screenshot() captures the currently visible viewport by default. Its fullPage option defaults to false.
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.
// Visible viewport only (the default)
await page.screenshot({ path: 'viewport.png' });
// Entire scrollable page
await page.screenshot({ path: 'full-page.png', fullPage: true });
Use viewport-only output when the screenshot should show exactly the selected browser window area. Use fullPage: true when the goal is a page-length capture rather than a fixed-height viewport image. These modes produce different image dimensions even when the viewport is unchanged. The option is documented in the Page API.
Choose screenshot pixel scale deliberately
The Page API’s scale option determines whether the output image uses CSS pixels or device pixels. The documented default is 'device'; choose 'css' for one output pixel per CSS pixel.
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
// Output at CSS-pixel scale
await page.screenshot({ path: 'css-scale.png', scale: 'css' });
// Device-pixel scale (the documented default)
await page.screenshot({ path: 'device-scale.png', scale: 'device' });
This matters when you compare image dimensions or feed screenshots into a system expecting a particular pixel size. A 1280-by-720 CSS viewport does not by itself guarantee a 1280-by-720 image at device scale.
Quick wins for a faster PC:
Scan for outdated or missing drivers - takes under a minuteDriver Scan →Repair Windows errors before they cause bigger problemsFix Now →Make visual comparisons repeatable
For screenshot assertions in Playwright Test, use expect(page).toHaveScreenshot(). Playwright cautions that rendering can vary with the host operating system, browser version, settings, hardware, power source, and headless mode. Generate and compare baselines in a consistent environment, and review snapshots when regenerating them. See Playwright visual comparisons.
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.
For reliable comparisons, keep the viewport, screenshot scale, browser setup, and execution environment consistent. The screenshot assertion helps detect changes; it does not make different rendering environments identical.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Troubleshoot viewport screenshot issues
- The layout looks like a different screen size: Set width and height on the context or page before
page.goto(). Responsive sites can choose their layout during navigation. - The screenshot is taller than the viewport: Check whether the call includes
fullPage: true. Remove it for a viewport-only capture. - The image dimensions are larger than expected: Check the
scaleoption.'device'is the documented default; choose'css'for one image pixel per CSS pixel. - The page’s screen dimensions changed after resizing: This is documented behavior for
page.setViewportSize(). Setscreenandviewporton the browser context when both properties need control. - Visual snapshots differ across machines: Keep the browser and host environment consistent, including operating system, browser version, settings, hardware, power source, and headless mode; review changed baselines rather than assuming every difference is an application change.
Or skip the browser setup
For a screenshot API call, use ScreenshotNeo’s website screenshot API. Its API accepts screenshot options including viewport dimensions, and its one-call endpoint can return an image or PDF. See the ScreenshotNeo documentation for request parameters.
curl -G "https://api.screenshotneo.com/v1/shot"
-d access_key=YOUR_API_KEY
--data-urlencode url=https://example.com
-d width=1280
-d height=720
-o shot.webp
ScreenshotNeo removes cookie and consent banners, newsletter popups, and chat widgets before capture; each of those steps can be turned off. Bot checks, blank pages, and failed loads are not billed, and the response includes page-verdict and billing headers. Its MCP server lets AI agents use screenshot tools. The free plan includes 1,000 screenshots a month with no card; paid plans start at $5 for 3,000.
Crashes, 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 minuteWindows Errors? Fix Them Before They Spread
Repair common Windows errors and clear accumulated junk for a smoother, more stable PC - no reinstall needed.Free scan · no reinstallSign up for ScreenshotNeo’s free plan to get 1,000 screenshots a month without a card.
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.

