Some links on this page are affiliate links: if you buy through them we may earn a commission, at no extra cost to you.
To generate a Playwright HTML report with failure screenshots, set screenshot: 'only-on-failure' and configure the HTML reporter in playwright.config.ts. Then run npx playwright test --reporter=html and open the result with npx playwright show-report. Add a trace on retries when you need more than a still image to understand a failure.
Generate and open a Playwright HTML report
Playwright’s HTML reporter creates a folder containing a report that can be served as a web page. The report covers the tests in a run, including their browsers and durations. Generate it from your project directory:
-
Run
npx playwright test --reporter=html. -
After the run, open the report with
npx playwright show-report.Do these 3 things before closing this tab:
1Scan for outdated or missing drivers - takes under a minute2Clear out junk files and repair common Windows errors3Fix the driver behind crashes, sound loss and screen glitchesSpecial offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
The default report folder is playwright-report. The HTML report is a run-level view; screenshots and other test artifacts are stored with the test output, typically in test-results. Keep those locations distinct when you collect or publish artifacts from CI.
Choose when the report opens
For a local run, opening the report automatically can be convenient. In CI, set the HTML reporter’s open behavior to 'never' so a test run does not try to open a browser. This setting affects report opening, not screenshot capture.
import { defineConfig } from '@playwright/test';
export default defineConfig({
reporter: [['html', { open: 'never' }]],
});
The reporter also supports a title, output folder, host, port, and attachments base URL. Use those options when your report needs a different label, destination, serving address, or attachment location. The precise values should match how your team serves and retains the report; the default output folder is sufficient for the basic workflow.
Capture screenshots only when tests fail
Set the use.screenshot option in playwright.config.ts. Its supported values are 'off', 'on', and 'only-on-failure'. For failure evidence without taking a screenshot for every test, use 'only-on-failure':
Free tools Windows power users keep installed
One-click scans. No signup required.
import { defineConfig } from '@playwright/test';
export default defineConfig({
reporter: [['html', { open: 'never' }]],
use: {
screenshot: 'only-on-failure',
trace: 'on-first-retry',
},
});
This configuration pairs a failure screenshot with a trace on the first retry. Screenshots, videos, and traces normally go in the test output directory, typically test-results. The HTML report provides the run overview; use its test entries to inspect the available failure evidence.
Choose the capture scope
-
'off'disables automatic screenshot capture. -
'on'captures screenshots for tests, which creates more image artifacts to store and review. -
'only-on-failure'focuses automatic screenshots on failed tests, a practical setting when the goal is diagnostic evidence rather than a picture from every successful run.
These modes express a trade-off: broader capture gives more visual records, while failure-only capture limits artifacts to cases that need investigation. Decide based on how much test output your team intends to retain and inspect; no universal retention period or artifact-size figure is provided.
The Tool Desk
Outbyte PC Repair FREERepair Windows errors before they cause bigger problemsFix Now →Outbyte Driver Updater FREEFix the driver behind crashes, sound loss and screen glitchesFind Drivers →Attach a deliberate screenshot to a test
Automatic failure screenshots are not the only option. When a test needs a particular image—such as a screenshot taken at a meaningful point in its flow—save it under that test’s output path and attach it through TestInfo.attach. Include the PNG content type so report tooling can identify it as an image:
import { test, expect } from '@playwright/test';
test('attach a page screenshot', async ({ page }, testInfo) => {
await page.goto('https://example.com');
const screenshotPath = testInfo.outputPath('screenshot.png');
await page.screenshot({ path: screenshotPath });
await testInfo.attach('page screenshot', {
path: screenshotPath,
contentType: 'image/png',
});
await expect(page).toHaveTitle(/Example/);
});
Use the attachment approach when the image should be an explicitly named part of a test’s evidence. It differs from configuring automatic failure screenshots: the test itself decides when to take and attach the image. Reporters can use the content type to display the attachment appropriately.
Use traces when a screenshot is not enough
A screenshot records a visual state, but it does not explain the sequence that produced it. A trace offers more debugging context: Trace Viewer can show action snapshots, logs, source locations, network information, metadata, and attachments. Configure trace: 'on-first-retry' when you want that evidence for a retry without asking for a trace on every initial attempt.
The HTML report links to the trace for a test when one is available. Open that trace in Trace Viewer to move through the actions and inspect what the page and test were doing around the failure. For visual-regression review, trace attachments can also show expected images, actual images, and image diffs.
Windows Errors? Fix Them Before They Spread
Repair common Windows errors and clear accumulated junk for a smoother, more stable PC - no reinstall needed.Free scan · no reinstallCrashes, No Sound, or Screen Glitches?
Random freezes, missing sound and display glitches usually trace back to one bad driver. Find and replace yours safely.Free scan · under a minuteChoose evidence for the debugging question
-
Use a screenshot to answer, “What did the page look like at failure?”
-
Use a trace when you need action history and surrounding execution details to investigate how the test reached that state.
-
Use a deliberate attachment when the test has a specific image or other file that should be presented as part of its evidence.
Publish the report and preserve its artifacts
The report folder can be served locally as a web page or retained as a CI artifact. In a CI workflow, run the tests, collect the generated report folder and test output directory, and make both available to the people investigating the run. The report is the navigable test summary; the output directory is where screenshot, video, and trace files normally appear.
Quick wins for a faster PC:
Scan for outdated or missing drivers - takes under a minuteDriver Scan →Repair Windows errors before they cause bigger problemsFix Now →Plan artifact retention around the way your team works. Screenshots on every test, failure-only screenshots, traces, and manually attached files produce different sets of evidence. Retaining less can reduce the material available for later debugging; retaining more means more files for your CI system to keep. No fixed storage cost, artifact-size limit, or retention duration is established here, so those depend on your CI provider and team policy.
Report serving options
For an immediate local review, use npx playwright show-report. For a shared report, publish the report folder through your CI artifact mechanism or serve it as a web page. The HTML reporter supports configuration for its output folder, host, port, and attachments base URL, which can help align generation with a hosting setup. Ensure that any separately hosted attachments remain reachable from the report; a report page without its referenced evidence is less useful for debugging.
When choosing a CI reporting or test-observability service, check whether its artifact handling fits your team’s report, screenshot, trace, and attachment workflow. This article does not rank third-party CI providers or establish their retention policies.
Rank #4
Troubleshoot missing reports and screenshots
-
The report does not open after the test run. If the reporter is set to
open: 'never', that is intentional. Runnpx playwright show-reportto open the existing report.Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy. -
You cannot find the report folder. Check the default
playwright-reportlocation and confirm the test command used the HTML reporter. If you configured a different output folder, look there instead. -
A failed test has no automatic screenshot. Check that the project’s
use.screenshotsetting is not'off', and inspect the test output directory, typicallytest-results, rather than assuming the image is stored inside the report folder. -
There are screenshots for successful tests too. The configured value may be
'on'. Change it to'only-on-failure'if the desired scope is failure evidence. -
A custom attachment is not displayed as an image. Confirm that the attached file is a PNG and that
contentTypeis set to'image/png'.Recommended: PC Feels Slow? A Free Scan Shows What's Dragging Windows Down →Recommended: Crashes or Glitches? A Free Driver Scan Usually Finds the Culprit →Recommended: Fix Windows Errors and Clear Junk Files in Minutes - Free Scan →Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy. -
The report has a test result but little context for the failure. A screenshot gives visual evidence, not action history. Configure a trace such as
'on-first-retry'and inspect the trace link in the report.Best Value
-
A shared report opens but its evidence is unavailable. Check that the published report and the linked attachments are both reachable. If your setup serves attachments separately, review its attachments base URL configuration.
Or skip the browser setup
Playwright screenshots are the right choice for evidence tied to a test’s execution, retries, and trace. For a separate task—capturing a webpage by URL without setting up a browser—ScreenshotNeo is a website screenshot API and MCP server for developers. One GET request can return a PNG, JPEG, WebP, or PDF. Its clean-shot workflow accepts cookie or consent banners like a visitor and removes more than 60 known consent platforms, newsletter popups, and chat widgets before capture; each of those steps can be turned off. Bot checks or CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed, and response headers report the page verdict and billing status. Its MCP server exposes take_screenshot, get_page_info, and capture_pdf for AI agents, including Claude, Cursor, or any MCP client.
For the complete request options and API details, see the ScreenshotNeo documentation. This cURL example captures a URL and writes the returned image to a file:
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
Use your API key in place of YOUR_API_KEY. This URL-based capture is an alternative for standalone webpage screenshots; it does not replace Playwright’s test-run screenshots or trace evidence.
ScreenshotNeo’s Free plan includes 1,000 shots per month with no card; paid plans start at $5 for 3,000 shots. Every feature is available on every plan, and yearly billing gives two months free. Sign up for ScreenshotNeo’s free plan to get 1,000 screenshots a month with no card.
Frequently Asked Questions
Can I inspect a previous Playwright HTML report without rerunning tests?
Yes. Run npx playwright show-report for the existing report.
Can Playwright report visual-regression image comparisons?
Trace Viewer attachments can include expected images, actual images, and image diffs.
Quick Recap
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.

