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

Set Playwright’s viewport before navigating, then capture the page. In Windows, use the same Playwright API: configure a fixed width and height on a browser context, open the page, and call page.screenshot(). By default, the screenshot shows the visible viewport; set fullPage: true to capture the full scrollable page.

Capture a screenshot at a fixed viewport

Install Playwright and its Chromium browser in your project, then save this as a JavaScript file such as screenshot.js. The context-level viewport is set before the page is created or navigated, which avoids resizing a page after the site has already responded to its initial dimensions.

const { chromium } = require('playwright');

(async () => {
  const browser = await chromium.launch();
  try {
    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: 'screenshot.png' });
  } finally {
    await browser.close();
  }
})();

Run it from PowerShell or Command Prompt with node screenshot.js. The example uses Chromium and writes screenshot.png in the current working directory. Replace the URL and dimensions as needed. Playwright’s viewport width and height are measured in CSS pixels.

Install Playwright on Windows

  1. Install Node.js if it is not already available, then open PowerShell or Command Prompt in your project folder.
  2. Run npm init -y if the folder does not yet have a package file.
  3. Run npm install playwright to add the Playwright library.
  4. Run npx playwright install chromium to install the browser used by the example.
  5. Save the code as screenshot.js and run node screenshot.js.

Playwright’s viewport and screenshot APIs are general APIs rather than Windows-specific methods. The same code flow applies when the script runs on Windows.

Free tools Windows power users keep installed

One-click scans. No signup required.

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

Choose the right viewport and capture area

Set the viewport in a browser context

For one or more pages that should share a viewport, use browser.newContext({ viewport: { width, height } }) before creating pages. This makes the intended dimensions explicit at the point where the browser context is configured.

Set a page viewport before navigation

You can instead create a page and call page.setViewportSize({ width, height }) before page.goto(). Playwright’s Page API cautions that websites may react to viewport changes, so configure the size before navigation when a fixed initial layout is important. Playwright Page API

Rank #2
Dell Latitude 3190 11.6" HD 2-in-1 Touchscreen Laptop Intel N5030 1.1Ghz 4GB Ram 128GB SSD Windows 11 Professional (Renewed)
  • 1.1 GHz (boost up to 2.4GHz) Intel Celeron N5030 Quad-Core
  • 4GB DDR4 System Memory; 128GB Solid State Drive
  • 11.6" HD (1366 x 768) Multi-Touch Display
  • Combo headphone/microphone jack - Noble Wedge Lock slot - HDMI; 2 USB 3.1 Gen 1
  • Windows 11 Pro

Use the visible viewport or the whole page

page.screenshot({ path: 'screenshot.png' }) captures the currently visible viewport by default. To capture the full scrollable page, use page.screenshot({ path: 'screenshot.png', fullPage: true }). The viewport dimensions still determine the page’s layout; fullPage changes the captured area, not the layout width.

Configure a test or project viewport

When using Playwright Test, set the viewport for a project with use: { viewport: { width: 1280, height: 720 } } in the configuration, or set it for tests with test.use({ viewport: { width, height } }). Use context configuration for a shared browser context, page sizing for a single page, and test or project configuration when the setting belongs to a test suite. Playwright emulation guide

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #3
Dell Latitude 5420 14" FHD Business Laptop Computer, Intel Quad-Core i5-1145G7, 16GB DDR4 RAM, 256GB SSD, Camera, HDMI, Windows 11 Pro (Renewed)
  • 256 GB SSD of storage.
  • Multitasking is easy with 16GB of RAM
  • Equipped with a blazing fast Core i5 2.00 GHz processor.

Control image dimensions and appearance

Choose CSS or device pixel scale

The scale screenshot option controls output pixel density. Use scale: 'css' for one image pixel per CSS pixel. Use scale: 'device' for device-pixel output, which can produce images twice as large or more on high-DPI displays. For example:

await page.screenshot({
  path: 'screenshot.png',
  scale: 'css',
});

Select an image format

Playwright infers the format from the filename extension. PNG is the default; screenshot formats include PNG, JPEG, and WebP. Use a matching extension such as .jpg or .webp when you want those formats.

Rank #4
15.6 Inch Laptop Computer, N4020, 4GB DDR4 RAM, 128GB eMMC,with Windows 11
  • EFFORTLESS EVERYDAY PERFORMANCE: Powered by Intel Celeron N4020 processor and Windows 11 Home system, delivering reliable, low-power efficiency for daily tasks like document editing, email, online classes, and web browsing
  • 15.6-INCH FULL HD DISPLAY: Enjoy immersive visuals on the 15.6" FHD (1920x1080) anti-glare screen with micro-edge bezels. Delivers clear details and comfortable viewing for long study sessions, working on spreadsheets, and video playback
  • RESPONSIVE MULTITASKING & STORAGE: Built with 4GB LPDDR4 RAM and 128GB eMMC storage for smooth daily essential use. Expand your storage by up to 1TB via the integrated TF card slot to easily store movies, photos, and working files
  • ADVANCED CONNECTIVITY: Outfitted with 2x Full-Featured Type-C ports for data transfer, fast charging, and dual-monitor output, alongside 2x USB 3.2 Gen1 ports and a 3.5mm audio jack for complete peripheral compatibility
  • LIGHTWEIGHT & SILENT OPERATION: Slim and portable for effortless travel or commuting. Features a 1MP HD webcam for remote meetings, 38Wh battery with 45W Type-C fast charging, and a fanless silent design for peaceful work environments.

Use optional capture controls only when needed

  • animations: 'disabled' controls animations during capture.
  • caret: 'hide' hides the text caret.
  • clip crops the captured area.
  • style applies CSS during capture.

These options refine the image; they do not establish the viewport size. See the Playwright screenshot API for the complete screenshot options.

Make Windows screenshots more reproducible

Matching viewport dimensions is necessary for consistent responsive layout, but it does not guarantee pixel-identical output across machines. Playwright notes that rendering can vary with host operating system, browser version, settings, hardware, power source, and headless mode. For visual regression baselines, keep the execution environment and browser version consistent with the baseline. Playwright visual comparisons guidance

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Best Value
Sale
15.6 Inch Win 11 Laptop Computer, N4020, 4GB DDR4 RAM, 128GB Storage
  • WINDOWS 11 | STABLE PERFORMANCE: Powered by Intel Celeron N4020 processor and Windows 11 system, this laptop delivers stable performance for everyday computing tasks. It supports web browsing, online learning, document editing, email communication, and basic office work with optimized power efficiency, providing a practical and reliable experience for essential daily use for daily use.
  • 15.6” FHD IPS DISPLAY: Features a 15.6-inch Full HD IPS display with narrow bezels, offering wider viewing angles and clearer image details compared to standard panels. The improved screen-to-body ratio enhances visual experience for study, reading, document work, and video playback, making it suitable for both productivity and entertainment use.
  • 4GB DDR4 + 128GB eMMC STORAGE: Equipped with 4GB DDR4 memory and 128GB eMMC storage for everyday basics such as browsing, documents, email, and online learning platforms. The built-in TF card slot supports storage expansion up to 1TB, giving you more flexibility for files, photos, videos, and daily documents. TF card not included.
  • CONNECTIVITY & PORTS: Includes 1× TF card slot, 2× USB 3.2 Gen1 ports, and 2× full-featured Type-C ports (USB 3.2 Gen1). The Type-C ports support data transfer, charging, and video output, enabling flexible connection with external devices such as monitors, storage, and peripherals for daily work and study use.
  • LIGHTWEIGHT DESIGN | ONLINE COMMUNICATION: Designed with a slim, portable profile, this laptop is easy to carry for school, commuting, and travel. A built-in 1MP front camera supports online classes, video meetings, remote communication, and everyday conferencing. The 3300mAh battery works with the low-power system design to support practical daily use, while thermal optimization helps maintain quieter operation during extended tasks.

If the emulated screen size as well as the viewport matters, configure screen and viewport through browser.newContext(). Calling page.setViewportSize() resets the screen size; context options give you control over both and can also specify a device scale factor. Playwright emulation guide

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Troubleshooting

  • The screenshot has unexpected dimensions: Check the context’s viewport values and confirm they are set before navigation. If you use scale: 'device', the output pixel dimensions may exceed the CSS-pixel dimensions.
  • The image only shows the top portion of the site: That is the default viewport capture. Add fullPage: true if the requirement is to capture the full scrollable page.
  • The layout differs from the expected responsive version: Verify the width and height, and avoid changing the viewport after navigation. Sites can respond to viewport changes.
  • It works locally but differs from a visual baseline on another machine: Match the browser version and execution environment as closely as possible; viewport equality alone does not eliminate rendering variation.
  • Node reports that it cannot find Playwright or Chromium: Confirm that the script is running in the project where Playwright is installed, and install Chromium with npx playwright install chromium.

Or skip the browser setup

If you need a screenshot through an API rather than a local Playwright browser, ScreenshotNeo accepts one GET request with a URL and returns a PNG, JPEG, WebP, or PDF. For an image request, the basic cURL call is:

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 the request options. Cookie banners, popups, and chat widgets are removed before capture; each cleanup step can be turned off. Bot checks, blank pages, and failed loads are not billed, and responses identify the page verdict and billing status. An MCP server provides screenshot tools for AI agents, including Claude, Cursor, and other MCP clients. The free plan includes 1,000 screenshots a month with no card; paid plans start at $5 for 3,000 screenshots.

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

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

Frequently Asked Questions

Does Playwright use a different viewport API on Windows?

No. The viewport and screenshot workflow uses Playwright’s general APIs when running on Windows.

Does a fixed viewport guarantee identical screenshots on every computer?

No. Matching dimensions helps keep layout consistent, but browser and host environment differences can still affect rendering.

Quick Recap

Bestseller No. 1
HP 14' HD Laptop, Windows 11, Intel Celeron Dual-Core Processor Up to 2.60GHz, 4GB RAM, 64GB SSD, Webcam, Dale Pink (Renewed)
HP 14" HD Laptop, Windows 11, Intel Celeron Dual-Core Processor Up to 2.60GHz, 4GB RAM, 64GB SSD, Webcam, Dale Pink (Renewed)
14" diagonal, 1366x768 resolution, HD BrightView LED, Glossy NON-TOUCH Display
$249.99
Bestseller No. 2
Dell Latitude 3190 11.6' HD 2-in-1 Touchscreen Laptop Intel N5030 1.1Ghz 4GB Ram 128GB SSD Windows 11 Professional (Renewed)
Dell Latitude 3190 11.6" HD 2-in-1 Touchscreen Laptop Intel N5030 1.1Ghz 4GB Ram 128GB SSD Windows 11 Professional (Renewed)
1.1 GHz (boost up to 2.4GHz) Intel Celeron N5030 Quad-Core; 4GB DDR4 System Memory; 128GB Solid State Drive
$179.99
Bestseller No. 3
Dell Latitude 5420 14' FHD Business Laptop Computer, Intel Quad-Core i5-1145G7, 16GB DDR4 RAM, 256GB SSD, Camera, HDMI, Windows 11 Pro (Renewed)
Dell Latitude 5420 14" FHD Business Laptop Computer, Intel Quad-Core i5-1145G7, 16GB DDR4 RAM, 256GB SSD, Camera, HDMI, Windows 11 Pro (Renewed)
256 GB SSD of storage.; Multitasking is easy with 16GB of RAM; Equipped with a blazing fast Core i5 2.00 GHz processor.
$304.00

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.