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.

Use two different path strategies. Store visual-regression baselines with expect(page).toHaveScreenshot() and resolve them through testInfo.snapshotPath(). Store failure and retry diagnostics with page.screenshot() and testInfo.outputPath(), adding testInfo.retry only to the diagnostic name or directory. This keeps every retry pointed at the same expected image while preserving a separate artifact for each attempt on Windows, macOS, Linux and CI.

The configuration and examples below use Playwright Test’s documented path APIs, so paths remain inside Playwright’s managed snapshot or per-test output directories instead of depending on a developer’s absolute filesystem.

The normalization rule: baselines are stable, diagnostics are attempt-specific

A retry is another execution of the same test, not a new visual expectation. If the screenshot is the assertion’s baseline, its path must not contain the retry number. If the screenshot is evidence collected after a failure, the retry number is useful and should be retained.

Artifact API Retry in name? Where it belongs
Visual-regression baseline expect(page).toHaveScreenshot(name) with testInfo.snapshotPath(name, { kind: 'screenshot' }) when you need the resolved path No. All attempts compare with the same expected image. The configured snapshot directory
Failure or retry diagnostic page.screenshot({ path: testInfo.outputPath(...) }) Yes. Use testInfo.retry in a controlled segment. The current test’s isolated output directory

testInfo.retry is zero on the initial run, one on the first retry, and increases for later retries. Playwright keeps output paths isolated for each test, which prevents parallel workers from writing to one another’s files.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Elebase USB to USB C Adapter for iPhone 18 Pro Max,USBC Car Charger Adapter
  • Read Before You Buy — No Video Output: These adapters support charging and USB 2.0 data transfer, but cannot transmit video signals. Except for standard USB webcams (which use USB data only), they are not compatible with HDMI/DisplayPort cables, video-capable USB-C hubs, or docking stations with video output.
  • Convert USB-A Ports to USB-C: Designed to connect USB-C earphones, cables, flash drives, card readers, and other USB-C accessories to standard USB-A ports. Plug-and-play with no drivers or software required.
  • Aluminum Alloy Housing: Built with a sturdy aluminum alloy shell that aids in heat dissipation and protects against daily wear and scratches. Designed to maintain a stable and secure connection.
  • Compact & Travel-Friendly: The ultra-compact design allows the adapter to stay plugged into your device without blocking adjacent ports or adding bulk, reducing wear and tear on your original USB ports.
  • 12-Month Warranty: Backed by a 12-month manufacturer warranty for peace of mind. Designed to meet strict quality control standards for reliable everyday performance.

A cross-platform configuration that stays deterministic

Set a snapshot template whose identity comes from Playwright’s project and test-file tokens. Relative templates resolve from the configuration directory, and forward slashes are valid path separators on every supported platform.

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

export default defineConfig({
  snapshotPathTemplate: '__screenshots__{/projectName}/{testFilePath}/{arg}{ext}',
  retries: process.env.CI ? 2 : 0,
  use: {
    screenshot: 'only-on-failure',
    trace: 'on-first-retry',
  },
});

What each setting does

  • snapshotPathTemplate separates projects and test files while keeping the assertion argument ({arg}) and extension ({ext}) deterministic.
  • retries sets the maximum retry attempts globally. A project can set its own value, and test.describe.configure() can override it for a file or group.
  • screenshot: 'only-on-failure' asks Playwright to capture a diagnostic screenshot when a test fails.
  • trace: 'on-first-retry' limits trace collection to the first retry, reducing routine artifact volume while retaining a useful debugging trace.

Do not put an absolute path such as C:UsersAliceDesktopshots or /home/alice/shots in the template. Such roots differ between laptops and CI workers and can move artifacts outside the directory Playwright protects.

Complete test example: one baseline, one normalized diagnostic per attempt

This test deliberately keeps the baseline name constant and gives each runtime capture an attempt-aware path.

Rank #2
Anker USB-C Hub, 5-in-1 USB Hub for Laptops, 4K HDMI Multiport Adapter
  • 5-in-1 USB-C Hub: Experience comprehensive connectivity featuring a Power Delivery input, two USB-A 2.0 ports, a USB-A 3.0 port, and an HDMI port. (Note: The USB-C power delivery input port is only for connecting an external wall charger to power your laptop and cannot power peripheral devices.)
  • 90W Pass-Through Charging: Achieve optimal charging with 90W pass-through power to your laptop, supported by a total input of 100W, with the hub reserving 10W for operational efficiency. (Note: Wall charger not included.)
  • Quick Data Transfers: Accelerate your productivity with rapid data transfers using a high-speed 5Gbps USB 3.0 port and two 480Mbps USB 2.0 ports.
  • 4K HDMI Display: Enhance your visual experience with a hub capable of delivering 4K resolution at 30Hz in both mirror and extend modes. Please note that this hub is compatible with MacBook (macOS 12 and newer), Windows 10 and 11, ChromeOS, and laptops equipped with DP Alt Mode and Power Delivery. Note: This device is not compatible with Linux.
  • What You Get: Anker USB-C Hub (5-in-1, 4K HDMI), welcome guide, 18-month warranty, and our friendly customer service.
import { test, expect } from '@playwright/test';

test('checkout renders', async ({ page }, testInfo) => {
  await page.goto('https://example.com/checkout');

  // The expected image is the same for the initial run and every retry.
  await expect(page).toHaveScreenshot('checkout.png');

  // Runtime evidence is unique to this attempt.
  const attempt = testInfo.retry;
  await page.screenshot({
    path: testInfo.outputPath(
      'diagnostics',
      `checkout-retry-${attempt}.png`,
    ),
    fullPage: true,
  });
});

Why this does not create competing baselines

checkout.png is interpreted under the configured snapshot directory. A retry compares against that same file; it does not create checkout-retry-1.png as a new expectation. The diagnostic capture is separate and is written below the current test’s output directory, where it can coexist with traces, videos and other attempt artifacts.

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

Resolving a baseline path explicitly

Most tests only need toHaveScreenshot(). If a fixture, reporter or helper must know the exact path, resolve it with the test information object rather than rebuilding the path manually:

const baseline = testInfo.snapshotPath('checkout.png', {
  kind: 'screenshot',
});
console.log(`Baseline: ${baseline}`);

Playwright rejects snapshot path segments that escape the configured snapshot directory. Treat that protection as a feature: pass a fixed filename or a name produced by a controlled sanitizer, not raw user input.

Rank #3
Sale
Anker USB C Hub, 7in1 Multi-Port USB Adapter, 4K@60Hz USBC to HDMI Splitter
  • Sleek 7-in-1 USB-C Hub: Features an HDMI port, two USB-A 3.0 ports, and a USB-C data port, each providing 5Gbps transfer speeds. It also includes a USB-C PD input port for charging up to 100W and dual SD and TF card slots, all in a compact design.
  • Flawless 4K@60Hz Video with HDMI: Delivers exceptional clarity and smoothness with its 4K@60Hz HDMI port, making it ideal for high-definition presentations and entertainment. (Note: Only the HDMI port supports video projection; the USB-C port is for data transfer only.)
  • Double Up on Efficiency: The two USB-A 3.0 ports and a USB-C port support a fast 5Gbps data rate, significantly boosting your transfer speeds and improving productivity.
  • Fast and Reliable 85W Charging: Offers high-capacity, speedy charging for laptops up to 85W, so you spend less time tethered to an outlet and more time being productive.
  • What You Get: Anker USB-C Hub (7-in-1), welcome guide, 18-month warranty, and our friendly customer service.

Designing names that survive projects, browsers and operating systems

Use Playwright identity for baselines

When a repository has Chromium, Firefox and WebKit projects, include the project token in snapshotPathTemplate. Otherwise two projects can try to own one image even though their rendering engines differ. The template shown above gives each project and test file a deterministic location.

Use a controlled sanitizer for dynamic diagnostic names

URL paths, test titles and data-driven labels often contain slashes, colons or characters that are illegal on Windows. Keep dynamic text out of the path unless it has been sanitized and length-limited. A simple pattern is to map anything outside letters, numbers, dot, underscore and hyphen to an underscore, then append the retry number as a separate segment. Never accept an arbitrary absolute path from a test parameter.

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

Prefer forward slashes in configuration

The template can use / on Windows and POSIX systems. For runtime paths, let testInfo.outputPath() perform the platform-specific resolution; do not concatenate strings with a hard-coded backslash.

Rank #4
Sale
UGREEN USB to USB C Adapter Combo 4-Pack, 10Gbps USB C Converter Space Gray
  • Dual Converters, Infinite Potential:Includes 2× USB C male to USB A female adapters and 2× USB A male to USB C female adapters. Perfect for a wide range of uses—tablets with Bluetooth keyboards, expand USB ports on macbook, and more. Two different converters for all your daily needs
  • Next-Level 10Gbps & 3A Charging: No more slow 480Mbps, this usb to usb c adapter has a transfer speed of up to 10Gbps, allowing you to do more transferring in less time. This usb adapter fits both USB A and USB C charger, supporting up to 3A fast charging
  • Upgraded Exquisite Craftsmanship: With an aluminum alloy housing and metal connector, the usbc to usb adapter is extremely durable and sturdy. Rigorously tested to withstand more than 10,000 times of plugging and unplugging, ensuring long-lasting performance
  • Broad Compatible: The usb c to usb adapter widely supports all USB C/ USB A devices like laptops, tablets, cellphones, car chargers, and phone chargers. Such as compatible with MacBook Pro/Air 2023/2022, Thunderbolt 4/3 Devices,Apple MagSafe Watch 9/8/7/SE/Ultra, iPad Pro 2022/2021, Samsung Galaxy S23/S20/S10, and iPhone 17/16/15 Pro. Plug and play
  • Please Note: To reach 10Gbps speed, keep the cable under 3.3 ft. For USB A Male to USB C adapters, try flipping the USB C connector. USB C Male to USB A adapters support bidirectional 10Gbps transfer within 3.3 ft

Retry policy and artifact lifecycle

Choosing where retries apply

Set a repository default with top-level retries, use a project-specific value when browser behavior differs, and use test.describe.configure({ retries: n }) for a particularly unstable group. Keep the policy intentional: every extra attempt can produce another diagnostic directory and another browser start.

Keeping the initial failure visible

With screenshot: 'only-on-failure', Playwright records a failure screenshot without requiring every test to call page.screenshot(). The explicit capture in the example is useful when you need a known filename, a full-page image, or a screenshot at a particular point in cleanup. If both mechanisms are enabled, expect more than one image in the output directory and distinguish them by their generated names or your own diagnostics subdirectory.

Managing disk usage in CI

  • Publish the test-results directory as a CI artifact when a run fails.
  • Keep the snapshot directory under source control; keep runtime output out of it.
  • Use a bounded retry count and clean old test-results directories according to your CI retention policy.
  • Capture full-page diagnostics only where they add value; viewport screenshots are smaller and faster.

No general flakiness-reduction percentage or cross-platform performance figure is established by Playwright’s API documentation. Measure retry rates, artifact sizes and capture time in your own suite.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Best Value
Anker USB C Hub, 5-in-1 USBC to HDMI Splitter with 4K Display
  • 5-in-1 Connectivity: Equipped with a 4K HDMI port, a 5 Gbps USB-C data port, two 5 Gbps USB-A ports, and a USB C 100W PD-IN port. Note: The USB C 100W PD-IN port supports only charging and does not support data transfer devices such as headphones or speakers.
  • Powerful Pass-Through Charging: Supports up to 85W pass-through charging so you can power up your laptop while you use the hub. Note: Pass-through charging requires a charger (not included). Note: To achieve full power for iPad, we recommend using a 45W wall charger.
  • Transfer Files in Seconds: Move files to and from your laptop at speeds of up to 5 Gbps via the USB-C and USB-A data ports. Note: The USB C 5Gbps Data port does not support video output.
  • HD Display: Connect to the HDMI port to stream or mirror content to an external monitor in resolutions of up to 4K@30Hz. Note: The USB-C ports do not support video output.
  • What You Get: Anker 332 USB-C Hub (5-in-1), welcome guide, our worry-free 18-month warranty, and friendly customer service.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Common path failures and exact fixes

Symptom Likely cause Fix
A retry creates a new baseline filename. The retry number was inserted into the argument passed to toHaveScreenshot(). Keep the assertion argument constant, such as 'checkout.png'; put testInfo.retry only in diagnostic output.
Playwright reports that a snapshot path is outside the snapshot directory. An absolute path, .. segment or unsanitized value escapes the configured root. Use testInfo.snapshotPath() or a fixed, sanitized name under the configured template.
Runtime files overwrite one another in parallel workers. Tests write to a shared hand-built directory. Write through testInfo.outputPath(), which resolves inside the current test’s isolated output directory.
Windows fails while Linux passes. A dynamic name contains a colon, slash, reserved device name or an overlong path, or code concatenates POSIX and Windows separators. Sanitize dynamic segments, keep names short, use forward slashes in the template, and delegate runtime joining to outputPath().
Baselines from two browser projects collide. The snapshot template lacks project identity. Add {/projectName} (as in the example) and regenerate baselines intentionally for each project.
The expected image is correct but the diagnostic image is missing. The test exits before the manual capture, or the capture is outside the failure path you intended. Place the capture at the required checkpoint, verify that the browser is still open, and inspect the per-test output directory published by CI.
Too many files appear after retries. Every attempt writes full-page images, traces and videos. Use bounded retries, keep trace: 'on-first-retry', and reduce explicit captures to the checkpoints that answer the debugging question.

Verifying a normalized layout in CI

  1. Run the same test locally with retries disabled and confirm the baseline is under the configured snapshot directory.
  2. Run with one or more retries and inspect that every assertion still references the same baseline filename.
  3. Run two tests in parallel and confirm each diagnostic remains under its own output directory.
  4. Execute the job on a Windows worker and a POSIX worker; compare the logical layout, not the platform-specific separator characters in absolute paths.
  5. Publish both snapshots (for review) and test-results (for diagnostics) as separate CI artifacts.

When an external screenshot API is useful

Playwright remains the right choice for assertions tied to a browser session. For a standalone page capture—such as generating a reference image, documenting a deployed URL, or letting an AI workflow request a screenshot—you can use ScreenshotNeo instead of maintaining browser-installation and path plumbing.

Or skip the browser setup

ScreenshotNeo accepts one GET request and returns a PNG, JPEG, WebP or PDF. The API removes cookie-consent banners, newsletter popups and chat widgets before capture; bot checks, blank pages, timeouts, failed loads and cache hits are not billed, and response headers identify the page verdict and billing result. Its MCP server exposes take_screenshot, get_page_info and capture_pdf to Claude, Cursor and other MCP clients.

Use the documented request format at ScreenshotNeo’s API documentation:

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp

The free plan includes 1,000 screenshots each month with no card. Paid plans start at $5 for 3,000 screenshots; every feature is available on every plan, and yearly billing provides two months free. Create a free ScreenshotNeo account to try it.

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

Practical checklist

  • Keep the toHaveScreenshot() name stable across retries.
  • Resolve baselines with snapshotPath() when code needs the path.
  • Write diagnostics through outputPath(), never a shared absolute directory.
  • Record testInfo.retry only for runtime evidence.
  • Include project identity in snapshotPathTemplate.
  • Use forward slashes in templates and sanitize dynamic names.
  • Separate source-controlled snapshots from disposable test-results.
  • Test the layout on the operating systems and CI workers you support.

Frequently Asked Questions

Can I use the retry number in a visual baseline filename for a flaky test?

Only if each retry is intentionally a different expected state. For normal retry handling, keep one baseline so a retry verifies the same visual contract; put the number in a diagnostic path instead.

Where should a CI system upload these files?

Upload the configured snapshot directory as the reviewable baseline artifact and the per-run test-results directory as diagnostic evidence. Keeping them as separate artifacts prevents temporary retry files from entering source control.

Do forward slashes make absolute paths portable?

They make Playwright’s relative snapshot template portable, but an absolute machine-specific root is still not portable. Keep the template relative and let Playwright resolve it.

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.

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