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

The correct Playwright setting depends on what creates the image. For a one-off browser screenshot, set path in page.screenshot(). For Playwright Test artifacts, set the top-level outputDir. For a file owned by one test, use testInfo.outputPath(). Visual-regression baselines use snapshotPathTemplate or expect.toHaveScreenshot.pathTemplate, not outputDir.

Choose the setting that matches your screenshot

Playwright has several screenshot-producing interfaces, and each has its own destination rule. Mixing them is the usual reason an image appears in an unexpected folder.

What produces the file? Set this What it controls
Direct browser API page.screenshot({ path }) The exact file path for that call
Playwright Test artifacts outputDir Per-run and failure artifacts, including configured automatic screenshots
One file created by a test testInfo.outputPath() A path inside that test’s isolated output directory
Visual comparison baseline snapshotPathTemplate or expect.toHaveScreenshot.pathTemplate Stable snapshot files used by screenshot assertions
Failure-capture policy use.screenshot Whether Test captures screenshots, not where they are stored

Save a direct page.screenshot() file

Pass the destination as the path option. Relative paths are resolved from the Node process’s current filesystem context, normally the directory from which your test command is run. The parent directory must already exist, or you must create it first.

import { chromium } from 'playwright';
import { mkdir } from 'node:fs/promises';

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

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

await browser.close();

You can use an absolute path when a process-wide working directory is not reliable, such as a CI job. Prefer path.join() rather than hard-coding separators if your code runs on multiple operating systems.

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
Lexar D40E 128GB Dual USB 3.2 Gen 1 Type-C Jump Drive, Champagne Silver
  • USB-C 2-in-1 storage OTG: The Lexar JumpDrive Dual Drive D40E features USB Type-A and Type-C connectors in a slim, portable form factor for easy device compatibility
  • Transfer speeds up to 100MB/s: Based on internal testing, performance may vary depending upon the host device, interface, and usage conditions. 1MB=1,000,000 bytes
  • Plug and Play: Widely compatible with USB Type-C smartphones, tablets, laptops, Macs, and traditional Type-A devices, no software installation required. The 360° swivel design allows for easy switching between connectors without the hassle of losing a cap
  • Durable & Compact: The Lexar D40E USB memory stick features a metal enclosure, withstands temperatures from 0° to 50° C (32°F to 122°F), and is lightweight at 26g with dimensions of 70.4 x 16.9 x 11.7mm
  • Security & Warranty: Securely protects files using an advanced security software solution with 256-bit AES encryption. Backed by a Lexar 3-year limited warranty
import path from 'node:path';

const file = path.join(process.cwd(), 'artifacts', 'home.webp');
await mkdir(path.dirname(file), { recursive: true });
await page.screenshot({ path: file, type: 'webp', quality: 85 });

The extension should agree with the requested image type. Playwright supports PNG, JPEG and WebP output; JPEG does not support transparency, and WebP quality is relevant when you choose lossy output. The path option determines this individual file only; it does not change Playwright Test’s artifact directory or visual-baseline directory.

Set the Playwright Test artifact folder with outputDir

When you run Playwright Test, the default artifact directory is test-results under the package directory. Set outputDir in playwright.config.ts to move it.

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

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

With this configuration, traces, videos and screenshots produced as Test artifacts are written below ./artifacts. Playwright Test cleans the output directory at the start of a run. Do not place source-controlled files or permanent baselines there. Each test receives a unique subdirectory, which prevents parallel workers from overwriting one another.

Automatic screenshot capture

The use.screenshot option controls capture policy:

  • 'off' disables automatic screenshots.
  • 'on' captures screenshots for every test.
  • 'only-on-failure' captures them when a test fails.

This policy and the folder are separate decisions. Change use.screenshot when you need different capture frequency; change outputDir when you need a different artifact root.

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

Use a collision-safe path inside a test

If your test explicitly calls page.screenshot(), derive its filename from testInfo.outputPath(). Playwright creates a path inside that test’s output directory and keeps parallel tests isolated.

Rank #2
SANDISK 128GB Ultra Flair, USB-A Flash Drive, Up to 150MB/s Read Speeds
  • High-speed USB 3.0 performance of up to 150MB/s(1) [(1) Write to drive up to 15x faster than standard USB 2.0 drives (4MB/s); varies by drive capacity. Up to 150MB/s read speed. USB 3.0 port required. Based on internal testing; performance may be lower depending on host device, usage conditions, and other factors; 1MB=1,000,000 bytes]
  • Transfer a full-length movie in less than 30 seconds(2) [(2) Based on 1.2GB MPEG-4 video transfer with USB 3.0 host device. Results may vary based on host device, file attributes and other factors]
  • Transfer to drive up to 15 times faster than standard USB 2.0 drives(1)
  • Sleek, durable metal casing
  • Easy-to-use password protection for your private files(3) [(3)Password protection uses 128-bit AES encryption and is supported by Windows 7, Windows 8, Windows 10, and Mac OS X v10.9 plus; Software download required for Mac, visit the SanDisk SecureAccess support page]
import { test } from '@playwright/test';

 test('home page screenshot', async ({ page }, testInfo) => {
  await page.goto('https://example.com');
  const screenshotPath = testInfo.outputPath('screenshots', 'home.png');
  await page.screenshot({ path: screenshotPath, fullPage: true });
});

The returned path is governed by the configured outputDir. Its segments must remain inside testInfo.outputDir; attempts to escape that directory (for example with a parent traversal) cause an error. This makes outputPath() safer than constructing a shared filename such as artifacts/home.png when workers run concurrently.

When to use a stable filename instead

Use a deliberately stable path only when another system expects one fixed location and you control concurrency. Otherwise, two projects or retries can overwrite the same file. For reports and debugging, outputPath() is the safer default.

Put visual-regression snapshots in a dedicated folder

expect(page).toHaveScreenshot() compares the current render with a baseline. Those baselines are not ordinary Test artifacts, so changing outputDir does not relocate them. Configure a snapshot template.

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

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

A relative template resolves from the configuration directory. Documented tokens include {testDir}, {snapshotDir}, {testFileDir}, {testFilePath}, {testFileName}, {testFileBaseName}, {projectName}, {testName}, {arg}, {ext} and {platform}. Use tokens that distinguish test files, projects and platforms when the same test runs in multiple environments.

You can also set the global snapshotPathTemplate where supported by your installed Playwright release, or set an assertion-specific expect.toHaveScreenshot.pathTemplate. Some documentation pages describe newer configuration; check the version installed in your project before adopting a token or option.

Rank #3
2 Pack 64GB USB Flash Drive USB 2.0 Thumb Drives Jump Drive Fold Storage Memory Stick Swivel Design - Black
  • What You Get - 2 pack 64GB genuine USB 2.0 flash drives, 12-month warranty and lifetime friendly customer service
  • Great for All Ages and Purposes – the thumb drives are suitable for storing digital data for school, business or daily usage. Apply to data storage of music, photos, movies and other files
  • Easy to Use - Plug and play USB memory stick, no need to install any software. Support Windows 7 / 8 / 10 / Vista / XP / Unix / 2000 / ME / NT Linux and Mac OS, compatible with USB 2.0 and 1.1 ports
  • Convenient Design - 360°metal swivel cap with matt surface and ring designed zip drive can protect USB connector, avoid to leave your fingerprint and easily attach to your key chain to avoid from losing and for easy carrying
  • Brand Yourself - Brand the flash drive with your company's name and provide company's overview, policies, etc. to the newly joined employees or your customers

Examples for common project layouts

Keep artifacts and baselines separate

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

export default defineConfig({
  outputDir: './artifacts',
  expect: {
    toHaveScreenshot: {
      pathTemplate: './visual-baselines/{testFilePath}/{arg}{ext}',
    },
  },
});

Here, temporary run output is cleaned under artifacts, while visual baselines live under visual-baselines and can be reviewed or committed independently.

Save a named diagnostic image and an assertion baseline

import { test, expect } from '@playwright/test';

test('dashboard', async ({ page }, testInfo) => {
  await page.goto('https://example.com/dashboard');
  await page.screenshot({
    path: testInfo.outputPath('diagnostics', 'dashboard.png'),
    fullPage: true,
  });
  await expect(page).toHaveScreenshot('dashboard.png');
});

The explicit diagnostic image follows the test output folder; the assertion image follows the snapshot template. They are intentionally different files.

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

CLI and MCP commands are separate interfaces

Playwright’s CLI screenshot command has its own filename behavior and supports a custom filename. Its documented default is a generated timestamp filename in its output directory. Playwright MCP resolves relative filenames against the workspace root and has its own output-directory default. Neither behavior changes the JavaScript API’s path, Playwright Test’s outputDir, or visual snapshot templates. If a CLI or MCP capture is misplaced, read that interface’s command options rather than changing your Test configuration.

Troubleshoot an unexpected screenshot location

The folder is empty or the command fails

  • Parent directory missing: create it with mkdir(..., { recursive: true }) before calling page.screenshot().
  • Wrong working directory: log process.cwd() and use an absolute path or a path based on a known project directory.
  • Permissions: choose a writable directory in the CI container and verify the job user can create files there.

outputDir did not move my baseline

That is expected. Baselines from toHaveScreenshot() use snapshot templates. Configure snapshotPathTemplate or expect.toHaveScreenshot.pathTemplate instead.

Parallel tests overwrite a file

Replace a shared literal path with testInfo.outputPath(), or include project, test and worker information in your naming scheme. Keep every generated path inside the test output directory.

Rank #4
SIMMAX 32GB Memory Stick USB 2.0 Flash Drives Swivel Thumb Drive Pen Drive (32GB Purple)
  • GOOD VALUE PACKAGE - 1 Pack 32GB Memory Stick USB 2.0 Flash Drives with great cost performance and high quality.
  • BIG CAPACITY - The available capacity: 29.10GB-29.8GB, You can save the data of movies, music, photos, designs, programs, manuals, handouts in a high speed.Good performance in digital data storing, transferring and sharing with families, friends, workmates, clients and machines.
  • EASY TO USE & PLUG AND WORK - Support windows 7 / 8 / 10 / Vista / XP / 2000 / ME / NT Linux and Mac OS, Compatible with USB2.0 and below.
  • TWISTTURN DESIGN & EASY CARRY - The metal clip rotates 360° round the ABS plastic body which with rubber oil skin feeling finish. The capless design can avoid lossing of cap, and providing efficient protection to the USB port.
  • WARRANTY & SUPPORT - SIMMAX logo is laser printed on the USB connector surface, our products are of good quality and we promise that any problem about the product within one year since you buy.

The directory is wiped between runs

outputDir is cleaned at the start of a Playwright Test run. Store durable reports or approved visual baselines elsewhere, and copy artifacts out before a cleanup step if your CI pipeline needs them after the job.

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

The image is not the page you expected

This is a capture-timing issue, not a folder issue. Wait for the relevant locator, network state or application state before calling the screenshot API. For a full-page image, use fullPage: true; for one element, call the locator’s screenshot method and still pass its own path.

Performance, reliability and naming guidance

  • Use per-test output paths for parallel safety; avoid one global filename.
  • Use PNG for pixel-accurate comparisons and transparency; use JPEG or WebP when smaller files matter more than lossless pixels.
  • Keep temporary artifacts outside version control and commit only intentional visual baselines.
  • Include the browser project or platform in snapshot templates when rendering differs across browsers or operating systems.
  • Do not confuse a successful file write with a valid page state. Wait for the UI state you intend to document before capture.
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 single HTTP request instead of maintaining Playwright launch code and output-folder handling. Its API removes cookie and consent banners, newsletter popups and chat widgets before capture; bot checks, blank pages, timeouts, failed loads and cache hits are not billed, and the response reports the result in X-Page-Verdict and X-Billed headers. An MCP server supplies take_screenshot, get_page_info and capture_pdf tools for Claude, Cursor and other MCP clients.

See the ScreenshotNeo API documentation for parameters and response details.

cURL

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}`);

ScreenshotNeo includes 63 options such as full-page lazy-image loading, CSS-selector element capture, device presets, custom viewports, dark mode, retina scale, PDF page controls, custom CSS and JavaScript, click-before-capture, selector hiding, waits, request blocking, headers, cookies, user agents, authorization, timezone, geolocation, transparent backgrounds, resizing, configurable caching, signed image links, asynchronous webhooks, bulk capture of 100 URLs per call, usage reporting and an OpenAPI specification. The parameter names used by other screenshot APIs are also accepted, which can simplify migration.

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.

The Free plan includes 1,000 screenshots per month with no card. Paid plans start at $5 for 3,000 screenshots; every feature is available on every plan. Create a free ScreenshotNeo account.

Best Value
Sale
IMEASON Swivel Design 16GB USB Flash Drive with Keychain, USB 2.0 Portable Thumb Drive Memory Stick, FAT32 Format Flashdrive for Data Storage, Photos, Music, Files (Black, 16 GB)
  • 【16GB Flash Drive】USB flash drives with 16GB capacity, meet your needs of daily use on work, school, home and travelling for photos, music, videos, files storage and transfer. IMEASON thumb drives can be used to store different files, easy to data backup.
  • 【Metal Swivel Cap Design】USB thumb drive is metal swivel cover provides extra protection for the usb thumbdrive connector, no usb drive cap to lose; keychain design makes it easier to carry without worrying lose it.
  • 【Wide Compatibility】USB drive supports Windows 7/8/10/11 / Vista / XP / Unix / 2000 / ME / NT Linux and Mac OS, also Supports USB 2.0 and 1.1 ports. USB Stick support TV, desktop, notebook computer, car, audio and other device. The USB Memory Stick is your great data storage and transfer companion with traveling and working.
  • 【Easy to use】usb memory stick is plug and play without any software installation. Just simply plug the Flashdrive into the port of your USB-compatible devices such as computer, laptop to start data storage or transmission.
  • 【What You Get】16 GB USB Flash Drive Thumb Drive, The default format of the usb storage flash drive is FAT32.

FAQ

Does outputDir change where page.screenshot() writes?

No. An explicit page.screenshot() call writes exactly to its path; outputDir is a Playwright Test artifact setting.

Can I use an absolute screenshot path?

Yes. Absolute paths are useful when the process working directory varies, provided the directory is writable.

Should visual baselines be stored in test-results?

Usually no. Keep baselines in a deliberate snapshot directory so Test cleanup cannot remove them accidentally.

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

Why does a retry create another folder?

Playwright Test isolates test attempts and workers to prevent artifact collisions. Use the report’s generated paths or testInfo.outputPath() rather than assuming one fixed filename.

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.