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

Set a regular Playwright screenshot location with the path option: await page.screenshot({ path: 'screenshots/home.png' });. For an element, call locator.screenshot({ path: ... }). In Playwright Test, use testInfo.outputPath() for runner-managed artifacts, and configure snapshotPathTemplate when changing where toHaveScreenshot() baselines are stored.

The right choice depends on whether you are saving an ordinary image, a per-test artifact, or a visual-regression snapshot. The examples below show each path mechanism, how relative paths resolve, and how to avoid common cross-platform and CI problems.

Save a page screenshot to a specific folder

The path property is a file path, not a URL. Playwright writes the encoded image to that location when the screenshot call completes.

import { chromium } from 'playwright';

(async () => {
  const browser = await chromium.launch();
  const page = await browser.newPage();
  await page.goto('https://example.com');

  await page.screenshot({ path: 'screenshots/home.png' });
  await browser.close();
})();

This creates screenshots/home.png relative to the process working directory (normally the directory from which you run the Node command). The filename extension determines the format: use .png, .jpeg, or .webp as supported by your Playwright version. If you omit path, the image is returned as a buffer instead of being saved automatically.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Sale
Philips 24 Inch Computer Monitor FHD 100Hz VA VESA Flicker-Free, 241V8LB
  • 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

Use an absolute or constructed path

Construct paths with Node’s path module rather than concatenating slash characters. This keeps the same script working on Windows, macOS, and Linux.

import path from 'node:path';

const outputFile = path.resolve(process.cwd(), 'artifacts', 'pages', 'home.png');
await page.screenshot({ path: outputFile });

Relative paths are usually more portable in source control. Absolute paths are useful when a CI job exposes a known artifact directory.

Set the path for an element screenshot

Locator screenshots use the same option. Playwright captures the element’s bounding box after it is ready and saves only that region.

await page.locator('.header').screenshot({
  path: 'screenshots/header.png'
});

Prefer a stable locator (such as a role, test id, or unique CSS selector). If the locator matches multiple elements, strict-mode behavior can fail the call; make the locator unique with .first(), .nth(), or a more specific selector when that is intentional.

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

Use Playwright Test’s output directory

When the screenshot belongs to a test run, pass the testInfo fixture’s output path to page.screenshot. The runner chooses a per-test directory and keeps artifacts associated with retries and projects.

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
import { test } from '@playwright/test';

test('basic screenshot', async ({ page }, testInfo) => {
  await page.goto('https://example.com');
  await page.screenshot(testInfo.outputPath('screenshot.png'));
});

outputPath(name) returns a path intended for test output. This is preferable to a hard-coded screenshots/ folder when you want reports and CI artifact collection to find files automatically. The name can include subdirectories, provided the resulting path remains inside the test’s output directory.

Choose between a fixed folder and test output

Need Recommended path Result
One-off script or application artifact page.screenshot({ path }) Exactly the file and folder you specify
Diagnostic image from a Playwright Test testInfo.outputPath('name.png') Runner-managed, per-test output location
Visual regression baseline toHaveScreenshot() with a snapshot template Snapshot naming and comparison conventions

Change the path used by visual snapshots

expect(page).toHaveScreenshot() does not use the ordinary screenshot path. It creates and compares baseline files using Playwright Test’s snapshot rules. Configure their location with snapshotPathTemplate in playwright.config.ts.

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

export default defineConfig({
  testDir: './tests',
  snapshotPathTemplate: '{testDir}/__screenshots__/{testFilePath}/{arg}{ext}',
});

A relative template resolves from the configuration directory. The template can include these tokens:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  • {arg} — relative snapshot name supplied to the assertion, without its extension.
  • {ext} — extension, including the leading dot.
  • {platform} — current process.platform.
  • {projectName} — filesystem-sanitized project name.
  • {snapshotDir} — the project’s snapshot directory.
  • {testDir} — resolved test directory.
  • {testFileDir} — directories between the test directory and test file.
  • {testFileBaseName} — test filename without its final extension.
  • {testFileName} — test filename with extension.
  • {testFilePath} — path from testDir to the test file.
  • {testName} — filesystem-sanitized test title, including parent describes.

Organize snapshots with names or path segments

Pass a filename for a simple baseline:

await expect(page).toHaveScreenshot('landing.png');

Use an array when you want meaningful subdirectories without manually joining platform-specific separators:

await expect(page).toHaveScreenshot(['landing', 'desktop', 'home.png']);

By default, Playwright stores snapshots next to the test file in a separate snapshot directory. Explicit names and segments make large suites easier to navigate; a template is better when every project needs a consistent hierarchy.

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.

Make paths reliable in CI and across operating systems

Resolve from a known directory

A relative path follows the process working directory, which can differ between a local shell, an npm script, and a CI runner. Run the command from the project root or construct an absolute path from process.cwd() (for application scripts) or use testInfo.outputPath() (for tests).

Ensure parent directories exist

Do not assume a nested directory has already been created. Create it before a standalone capture:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
import { mkdir } from 'node:fs/promises';

await mkdir('artifacts/pages', { recursive: true });
await page.screenshot({ path: 'artifacts/pages/home.png' });

The test runner manages its own output directory, so testInfo.outputPath() is generally safer for test artifacts.

Use deterministic names

Repeated captures with the same filename overwrite the previous image. Include a case name, viewport, or timestamp when retaining multiple ordinary artifacts. Do not add timestamps to visual-regression baselines: changing the name prevents comparison with the existing baseline.

Keep snapshot environments consistent

Visual snapshots can differ with operating system, browser version, fonts, viewport, and device scale factor. If your suite intentionally maintains platform-specific baselines, include {platform} or {projectName} in snapshotPathTemplate. Otherwise, standardize the Playwright project and execution environment so a path change does not mask rendering differences.

Rank #4
Sale
Samsung 27" Essential S3 (S36GD) Series FHD 1800R Curved Computer Monitor
  • 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

Common path errors and fixes

“No such file or directory” or an ENOENT error

The parent folder is missing, or the relative path is resolving from an unexpected working directory. Create the directory with mkdir(..., { recursive: true }), print process.cwd(), and verify the path you pass.

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

The file is saved somewhere unexpected

Relative paths are based on the process working directory, not necessarily the directory containing the test file. Use path.resolve(), run from a documented project root, or switch to testInfo.outputPath().

Snapshot files appear in the default location

snapshotPathTemplate affects toHaveScreenshot(), not page.screenshot({ path }). Confirm the setting is exported from the configuration file that the test command loads, and check that the assertion is using the intended project.

Windows separators break a hard-coded path

Use path.join() or an array of snapshot path segments. Avoid embedding a backslash- or slash-specific path in shared test code.

The screenshot call fails before writing a file

Check that navigation has completed, the page or locator is still attached, and the destination is writable. For an element capture, make the locator unique and wait for the component to render. A failed capture does not produce a valid image, so inspect the original exception rather than trying to rename a missing file.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
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.

Baselines are unexpectedly different

This is usually an environment or rendering issue rather than a path issue. Verify browser, viewport, fonts, color scheme, and device scale factor, then regenerate baselines deliberately only after confirming the UI change is expected.

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

Or skip the browser setup

If you only need a URL rendered to an image or PDF, ScreenshotNeo provides a website screenshot API. It accepts a URL in one request and supports PNG, JPEG, WebP, and PDF output. A cURL example is:

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 and response handling. The equivalent Python and Node.js calls are:

import requests
r = requests.get("https://api.screenshotneo.com/v1/shot", params={"access_key": "YOUR_API_KEY", "url": "https://stripe.com"}, timeout=90)
open("shot.webp", "wb").write(r.content)
const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://stripe.com' });
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);
  • Cookie and consent banners, newsletter popups, and chat widgets are removed before the shot; each cleanup step can be turned off.
  • Bot checks or CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed as clean shots. Response headers identify the page verdict and whether it was billed.
  • An MCP server lets Claude, Cursor, and other MCP clients call take_screenshot, get_page_info, and capture_pdf.
  • The Free plan includes 1,000 screenshots per month without a card; paid plans start at $5 for 3,000 shots. Every feature is available on every plan.

Create a free ScreenshotNeo account to get the 1,000 monthly screenshots with no card.

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.

Quick decision guide

  • Use page.screenshot({ path }) when your code owns the filename and folder.
  • Use locator.screenshot({ path }) for a component or region.
  • Use testInfo.outputPath() for diagnostic artifacts that should follow each test’s output directory.
  • Use snapshotPathTemplate and explicit assertion names for visual baselines.
  • Use path helpers and deterministic naming when tests run on multiple operating systems or workers.

Frequently Asked Questions

Can I save a screenshot returned as a buffer later?

Yes. Omit the path, receive the returned buffer, and write it with Node’s filesystem APIs when you need custom naming or post-processing.

Does setting snapshotPathTemplate move screenshots made with page.screenshot()?

No. It controls Playwright Test snapshot assertions such as toHaveScreenshot(); ordinary page or locator screenshots still use the path you pass directly.

What is the safest path choice for parallel tests?

Use testInfo.outputPath() for per-test artifacts, or include stable test and project tokens in snapshotPathTemplate so workers do not overwrite one another.

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.

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.