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

Some links on this page are affiliate links: if you buy through them we may earn a commission, at no extra cost to you.

Playwright does not use one universal screenshot folder. The location depends on how the image was produced. A direct page.screenshot() or locator.screenshot() call saves only when you provide a path; a relative path is resolved from the process’s current working directory. Playwright Test artifacts normally go to the configured outputDir (by default, a test-results directory beside package.json). Visual assertion baselines, report attachments and trace images follow separate storage rules.

Find the producing API first, then inspect its path or configuration. The sections below show exactly what to check and how to make the destination explicit.

Quick location map

How the image was created Where it goes What to inspect
page.screenshot() or locator.screenshot() The path you pass. A relative path starts at the Node.js process’s current working directory. With no path, Playwright returns bytes and creates no file. The screenshot call and the directory from which you launched the command.
Playwright Test screenshot, video or trace artifact The configured outputDir; when unset, typically test-results under the package directory. Each test gets its own subdirectory. playwright.config.*, testInfo.outputDir and testInfo.outputPath().
expect(page).toHaveScreenshot() The visual-snapshot path generated by the configured snapshot template, not the ordinary test output directory. snapshotPathTemplate and an assertion-level pathTemplate, if present.
testInfo.attach() A reporter-accessible attachment location. The report can contain the image even if your code never created a conveniently named standalone file. The report’s Attachments area and the code that calls attach.
Tracing screenshots Inside the trace file and its visual timeline, viewed with Trace Viewer. Tracing configuration and the trace path, rather than a PNG filename.

Direct screenshots: the path is the answer

When a path is supplied

This call writes a file:

import { chromium } from 'playwright';

const browser = await chromium.launch();
const page = await browser.newPage();
await page.goto('https://example.com');
await page.screenshot({ path: 'artifacts/home.png', fullPage: true });
await browser.close();

If you start the script from /work/site, the relative destination is /work/site/artifacts/home.png. It is not automatically relative to the JavaScript file, the test file or playwright.config.ts. Create the parent directory yourself when your script does not already do so:

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', { recursive: true });
await page.screenshot({ path: 'artifacts/home.png' });

An absolute path removes ambiguity:

await page.screenshot({ path: '/tmp/playwright/home.png' });

When no path is supplied

await page.screenshot() returns image bytes; it does not save a disk file. You must write the returned buffer yourself:

#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
const image = await page.screenshot({ type: 'png' });
await writeFile('/tmp/home.png', image);

The same rule applies to locator.screenshot(). A common mistake is searching the repository for a PNG after calling the method without path; there is no standalone file to find unless subsequent code persisted the buffer.

Confirm the runtime directory

Print the directory that resolves relative paths:

console.log('cwd:', process.cwd());

In npm scripts, IDE launchers, containers and CI, the working directory can differ from the directory containing your source file. Log the resolved filename when diagnosing a missing image:

import path from 'node:path';
const target = path.resolve('artifacts/home.png');
console.log('screenshot:', target);
await page.screenshot({ path: target });

Playwright Test artifacts

Default and custom output directories

Playwright Test stores screenshots, videos and traces in its test output directory. If you do not set one, the documented default is typically test-results under the directory containing package.json. A project can override it:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
// playwright.config.ts
import { defineConfig } from '@playwright/test';

export default defineConfig({
  outputDir: 'artifacts/test-output',
  use: {
    screenshot: 'only-on-failure'
  }
});

With this configuration, inspect artifacts/test-output, not a folder beside the test file. Playwright creates a unique subdirectory for each test, which prevents collisions when workers run tests in parallel.

Use testInfo instead of guessing

For deterministic paths inside the current test’s output directory, use the test information object:

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('save a diagnostic image', async ({ page }, testInfo) => {
  await page.goto('https://example.com');
  const file = testInfo.outputPath('diagnostics', 'page.png');
  await page.screenshot({ path: file, fullPage: true });
  console.log('saved to', file);
});

testInfo.outputDir tells you the current test’s directory. testInfo.outputPath() constructs a path within it and is safer than concatenating a guessed folder name.

Automatic failure screenshots

If use.screenshot is set to 'only-on-failure' or 'on', those images are test-run artifacts and appear under outputDir. A passing test with 'only-on-failure' normally produces no screenshot. Check the active project configuration: a different project in the same config can have different settings.

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.

Visual regression snapshots

expect(page).toHaveScreenshot() is not the same as a diagnostic page.screenshot({ path }). It creates and compares baseline snapshots using Playwright Test’s snapshot path configuration. A relative snapshot template is resolved from the configuration directory, and projects can customize the location with snapshotPathTemplate. An individual assertion can also supply a path template.

// playwright.config.ts
import { defineConfig } from '@playwright/test';

export default defineConfig({
  snapshotPathTemplate: '{snapshotDir}/{projectName}/{testFilePath}/{arg}{ext}'
});

When a baseline cannot be found, inspect this template and the project name before looking in test-results. Snapshot files are intentionally separate from ordinary run artifacts so that baselines can be reviewed and versioned independently.

Attachments and reports

testInfo.attach() makes a file or buffer available to reporters:

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

 test('attach screenshot', async ({ page }, testInfo) => {
  const image = await page.screenshot();
  await testInfo.attach('page', {
    body: image,
    contentType: 'image/png'
  });
});

This code receives bytes and attaches them to the test report; it does not promise a permanently named PNG beside the test source. Open the generated report and its attachment panel to retrieve the image. If you need a predictable filesystem artifact as well, pass a path to page.screenshot() or write the buffer to a path before attaching it.

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

Trace screenshots are inside the trace

Tracing records screenshots as part of the trace’s visual timeline. They are viewed by opening the trace in Trace Viewer, not by searching for a sequence of ordinary image files. The trace itself is saved at the path configured by your tracing setup or by the command that exports it. Treat a trace image as trace content unless your test separately calls a screenshot API with a path.

A reliable way to find an existing screenshot

  1. Search the code for page.screenshot, locator.screenshot, toHaveScreenshot, testInfo.attach and tracing setup.
  2. If the call has path, resolve a relative value against process.cwd(); print path.resolve(pathValue) to verify it.
  3. If there is no path, determine whether the returned buffer is written elsewhere or only attached to a report.
  4. For test-run artifacts, inspect the active configuration’s outputDir. If it is unset, check the package directory’s test-results.
  5. For a test-specific location, log testInfo.outputDir or the result of testInfo.outputPath().
  6. For visual assertions, inspect snapshotPathTemplate and any assertion-level template.
  7. For attachments, open the reporter output. For tracing, open the trace in Trace Viewer.

Troubleshooting missing files

“The screenshot call succeeded, but no PNG exists”

Most often, no path was supplied. Save the returned buffer with writeFile, or add an explicit absolute path.

“I looked beside the test file”

Relative direct paths use the process working directory. Test artifacts use outputDir, and snapshots use their template. Print process.cwd() and inspect the configuration rather than moving files randomly.

“The folder is empty after a successful test”

Automatic screenshots may be configured as only-on-failure. Trigger the failure intentionally or change the setting temporarily. Also verify that you are inspecting the active project and output directory.

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

“Parallel tests overwrite each other”

Do not construct one shared filename such as latest.png. Use testInfo.outputPath() or include a test-specific identifier. Playwright Test’s per-test output directories are designed to avoid these collisions.

“The snapshot is not where the report artifact is”

That is expected: assertion baselines and test-run artifacts have different path systems. Check the snapshot template for the former and outputDir for the latter.

“The report shows an image, but I cannot find a file”

The image may exist only as a reporter attachment. Retrieve it from the report or explicitly persist a second copy in your test.

“CI cannot create the destination”

Use a writable workspace path, create parent directories with mkdir(..., { recursive: true }), and log the resolved destination. Containerized or read-only runners can reject an otherwise valid path.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Make screenshot storage predictable

  • Choose separate directories for human-reviewed artifacts, visual baselines and temporary diagnostics.
  • Use absolute paths at integration boundaries, or derive them from testInfo.outputPath().
  • Log the resolved path on failure so CI logs answer the location question immediately.
  • Keep large artifacts out of source control unless they are intentional visual baselines.
  • Record the screenshot type and producing mechanism when uploading artifacts; a trace image and a PNG file are not interchangeable.

Or skip the browser setup

If your goal is simply to obtain a clean website image rather than debug a Playwright run, ScreenshotNeo returns a screenshot from one request. Before capture it accepts cookie or consent banners and removes more than 60 known consent platforms, newsletter popups and chat widgets; each cleanup step can be disabled. Bot checks or CAPTCHAs, blank pages, timeouts, failed loads and cache hits are not billed, and response headers identify the page verdict and billing result. Its MCP server provides take_screenshot, get_page_info and capture_pdf tools for Claude, Cursor and other MCP clients. Every plan includes the features; the Free plan includes 1,000 shots per month without a card, while paid plans start at $5 for 3,000 shots.

See the parameter details in the ScreenshotNeo documentation. cURL:

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.
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp

Python:

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)

Node.js:

const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://stripe.com' });
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);

Create a free ScreenshotNeo account to get 1,000 screenshots a month with no card; paid plans start at $5 for 3,000.

Frequently Asked Questions

Does Playwright save screenshots next to the test file by default?

No. Direct relative paths use the process working directory, while Playwright Test artifacts and visual snapshots use their own configured locations.

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

Can I use one path rule for screenshots, snapshots and traces?

No. They are separate mechanisms: ordinary screenshot paths, test output directories, snapshot templates and trace files must be configured or inspected independently.

How can I print the exact path during a test?

Resolve a direct path with Node’s path.resolve(), or log testInfo.outputDir and the value returned by testInfo.outputPath().

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.