Set the browser page viewport to the required width and height before navigating, then take a normal screenshot. For example, a 1280 × 720 viewport produces a screenshot of the visible page area at those dimensions when captured at CSS-pixel scale. This fixes the webpage’s layout viewport—not the outer operating-system window with browser tabs and controls.
Set a fixed viewport with Playwright
Install Playwright and its browser for your project, then configure the page before loading the target URL. This complete Node.js example saves the visible viewport as page.png:
As an Amazon Associate I earn from qualifying purchases.
import { chromium } from 'playwright';
const browser = await chromium.launch();
const page = await browser.newPage();
await page.setViewportSize({ width: 1280, height: 720 });
await page.goto('https://example.com');
await page.screenshot({ path: 'page.png' });
await browser.close();
Replace the URL and dimensions as needed. Width and height are pixels for the webpage viewport. Set the viewport before navigation: responsive pages may lay themselves out based on the size they see when first loaded. Playwright recommends this ordering because many websites do not expect a page to change size after navigation. Playwright page API
Do these 3 things before closing this tab:
1Clear out junk files and repair common Windows errors2Scan for outdated or missing drivers - takes under a minute3Repair Windows errors before they cause bigger problemsApply the dimensions to multiple pages
If your agent creates several pages in the same browser context, set the viewport when creating that context rather than resetting it page by page:
#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 context = await browser.newContext({
viewport: { width: 1280, height: 720 }
});
const page = await context.newPage();
await page.goto('https://example.com');
await page.screenshot({ path: 'page.png' });
Use context-level screen configuration as well if the page needs screen dimensions controlled separately. Calling page.setViewportSize() also resets the screen size. See Playwright browser context options.
Choose viewport or full-page capture
A normal page.screenshot() captures what is visible inside the viewport. It does not capture the full scrollable document. If you need the whole page instead, explicitly request it:
await page.screenshot({ path: 'whole-page.png', fullPage: true });
A full-page image is taller than the viewport, so do not enable fullPage when the output must remain exactly 1280 × 720. For a specific part of the page, Playwright also supports element screenshots; see its screenshot guide.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
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
Control screenshot pixel scale
The viewport dimensions describe CSS pixels. Playwright’s screenshot scale option determines how those pixels map to image pixels:
scale: 'css'produces one image pixel per CSS pixel, which is the clearest choice when you need predictable output dimensions tied to the viewport.scale: 'device'uses device pixels. On a high-density display, the resulting image can be larger than the CSS viewport dimensions.
For a 1280 × 720 image, use CSS scale explicitly when the installed Playwright version supports the option: await page.screenshot({ path: 'page.png', scale: 'css' });. Check the screenshot API options for the version installed in your project.
Python and Puppeteer alternatives
Python with Playwright
Create the page with its viewport before navigation. This asynchronous example saves the visible viewport:
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.
from playwright.async_api import async_playwright
async def main():
async with async_playwright() as p:
browser = await p.chromium.launch()
page = await browser.new_page(viewport={"width": 1280, "height": 720})
await page.goto("https://example.com")
await page.screenshot(path="page.png")
await browser.close()
Run the function from your application’s async entry point. Playwright APIs and options can evolve, so consult the documentation for the version installed in your environment.
JavaScript with Puppeteer
If your agent already uses Puppeteer, set the page viewport before navigating:
const page = await browser.newPage();
await page.setViewport({ width: 1280, height: 720 });
await page.goto('https://example.com');
await page.screenshot({ path: 'page.png' });
Puppeteer likewise recommends setting the viewport before navigation for pages that respond to size changes. Some mobile or touch configurations can reload the page when the viewport is set; see the Puppeteer viewport API.
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
Make repeated captures more consistent
A fixed viewport is necessary for repeatable screenshots, but it does not guarantee pixel-identical images on different machines. Rendering can vary with operating system, browser version, browser settings, hardware, power source, and headless mode. For visual comparisons, keep the browser version, execution environment, viewport, and capture settings stable. Playwright describes these sources of rendering variation in its visual comparison documentation.
- Set viewport dimensions before navigation.
- Use CSS scale when the output should map one-to-one to CSS pixels.
- Keep the browser and host environment consistent across runs.
- Choose ordinary viewport capture or full-page capture deliberately; they produce different image dimensions.
Troubleshooting fixed-size screenshots
The image has unexpected dimensions
Check whether you enabled fullPage: true; that makes the image taller than the viewport. Also check the screenshot scale: device scale can produce more image pixels than CSS pixels. Use a normal viewport screenshot and CSS scale when exact CSS-pixel dimensions are needed.
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 reinstallThe page looks like the wrong responsive layout
Set width and height before goto(), not after the page has loaded. If you use a context, pass viewport to browser.newContext() before creating pages.
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.
Images differ between runs despite the same viewport
Compare the browser version, operating system, rendering settings, hardware, and headless mode. Keep the execution environment stable as well as the viewport; size alone cannot control all rendering differences.
I need the actual desktop window size
Playwright’s viewport APIs control the webpage’s layout area, not the browser’s outer window including tabs and controls. The documented page APIs here do not provide a host-level capture workflow for that different requirement.
Or skip the browser setup
ScreenshotNeo offers a screenshot API and MCP server for AI agents. One GET request can return a screenshot or PDF, without setting up Playwright or Puppeteer in your agent:
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://example.com -o shot.webp
See the ScreenshotNeo API documentation for request options. Cookie banners, newsletter popups, and chat widgets are removed before the shot; each cleanup step can be turned off. Bot checks, blank pages, and failed loads are not billed, and the response identifies the page verdict and billing status. Its MCP server lets AI agents use screenshot tools, and the free plan includes 1,000 screenshots a month with no card; paid plans start at $5 for 3,000 shots. Sign up for ScreenshotNeo’s free plan.
Frequently Asked Questions
Does a fixed viewport set the browser window size?
No. It sets the webpage’s layout viewport, not the outer operating-system window and its browser controls.
Will 1280 × 720 always produce a 1280 × 720 file?
For a normal viewport capture using CSS scale, it maps to one screenshot pixel per CSS pixel. Full-page capture or device-pixel scale can produce different dimensions.
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.
The Tool Desk
Outbyte PC Repair FREERepair Windows errors before they cause bigger problemsFix Now →Outbyte Driver Updater FREEFix the driver behind crashes, sound loss and screen glitchesFind Drivers →




