The Tool Desk
Outbyte PC Repair FREEClear out junk files and repair common Windows errorsFree Scan →Outbyte Driver Updater FREEScan for outdated or missing drivers - takes under a minuteDriver Scan →Set use.screenshot to 'only-on-failure' in playwright.config.ts to have Playwright capture a screenshot whenever a test fails:
import { defineConfig } from '@playwright/test';
export default defineConfig({
use: {
screenshot: 'only-on-failure',
},
});
Playwright stores the resulting artifact in the configured test output directory (commonly test-results) and your reporter displays it with the failed test. Use 'on-first-failure' to avoid duplicate images when retries run, or use page.screenshot() with testInfo.attach() when you need a specific capture point, filename, or full-page image.
Choose the right failure-screenshot method
| Method | Best for | What it captures | Artifact volume |
|---|---|---|---|
use.screenshot: 'only-on-failure' |
Most test suites | Automatically after a failed test | One image per failure (and potentially per retry) |
use.screenshot: 'on-first-failure' |
Projects using retries | The first failure for each test | Fewer duplicate images |
page.screenshot() plus testInfo.attach() |
Custom timing, naming, or options | Exactly where your code requests it | Only the attachments you create |
step.attach() |
Debugging a particular test.step |
An image attributed to one step | Step-level artifacts |
The automatic setting is normally the best starting point. A custom hook is useful when the failure state changes quickly, when you need a full-page image, or when you want a named attachment alongside logs and traces.
Configure automatic screenshots after failures
Minimal configuration
Place this in the exported configuration object:
import { defineConfig } from '@playwright/test';
export default defineConfig({
use: {
screenshot: 'only-on-failure',
},
});
The option is under use, so it applies to tests using the project unless a project or test-specific setting overrides it. The default is 'off'. The other documented modes are 'on', which captures every test, 'only-on-failure', and 'on-first-failure'.
#1 Best Overall
- 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.
Capture a full page
Automatic screenshots use Playwright’s screenshot behavior. For a guaranteed full-scrollable-page image, use an explicit screenshot in a hook or in the test itself with fullPage: true. This is often more useful for pages where the defect is below the initial viewport.
Transparency
When the browser and image format support it, omitBackground: true removes the default background and preserves transparency. This option is available on the screenshot API; use a custom capture when you need to set it explicitly.
Use a custom screenshot and attach it to the test
Call page.screenshot() at the point that still shows the useful failure state, then attach the returned bytes with testInfo.attach():
import { test } from '@playwright/test';
test('checkout', async ({ page }, testInfo) => {
await page.goto('https://example.test/checkout');
const screenshot = await page.screenshot({ fullPage: true });
await testInfo.attach('checkout-screenshot', {
body: screenshot,
contentType: 'image/png',
});
});
page.screenshot() returns a buffer when no path is supplied. Passing that buffer as body keeps the artifact under the test runner’s control. testInfo.attach() also accepts a filesystem path if another tool has already written the image. Playwright copies the attachment to a reporter-accessible location, so reporters can expose it without relying on your working directory.
Attach at a particular step
For step-level attribution, attach inside test.step and use the callback’s step object:
Rank #2
- 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 } from '@playwright/test';
test('profile update', async ({ page }) => {
await test.step('submit profile form', async ({ step }) => {
await page.getByRole('button', { name: 'Save' }).click();
await step.attach('after-save', {
body: await page.screenshot({ fullPage: true }),
contentType: 'image/png',
});
});
});
A step attachment is attributed to that step, whereas testInfo.attach() stores the artifact at test level. Choose the level that matches how your reporter groups evidence.
Capture only when the final result is unexpected
If you need a policy that evaluates the completed result, add an afterEach hook. Compare testInfo.status with testInfo.expectedStatus while the page fixture is still available:
import { test } from '@playwright/test';
test.afterEach(async ({ page }, testInfo) => {
if (testInfo.status !== testInfo.expectedStatus) {
await testInfo.attach('failure-screenshot', {
body: await page.screenshot({ fullPage: true }),
contentType: 'image/png',
});
}
});
This condition also identifies an unexpected pass: a test marked as expected to fail that passes has a status different from its expected status. If you want images only for ordinary failures and not unexpected passes, test for the status value your project treats as a failure instead of using the general inequality.
Why the hook must run before the page is gone
Fixtures are torn down as the test lifecycle ends. Taking the screenshot in afterEach keeps the page fixture available. A later global teardown may no longer have the browser page that displayed the error.
Retries, projects, and artifact volume
Retries can create duplicate evidence
With only-on-failure, a screenshot can be produced for each failed attempt. That is valuable when a retry succeeds—you can compare the failed attempt with the passing one—but it can produce several similar files for a consistently failing test. Choose on-first-failure when the first failed attempt is enough and artifact volume matters.
Rank #3
- 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.
Keep project context in the filename
When several browser projects run the same test, let the Playwright reporter’s test and project metadata distinguish the attachments. If you create files yourself, include the project or scenario name in your attachment name rather than writing to one shared filename, which can be overwritten by parallel workers.
Viewport versus full page
- Viewport capture: smaller and faster; best for a dialog, button, or layout issue visible at the failure point.
- Full-page capture: includes the scrollable document; best for missing content, long forms, and responsive pages where the defect is lower down.
Full-page images can be substantially larger. Use them selectively in high-volume suites, particularly when traces or videos are already enabled.
Where Playwright saves failure screenshots
Playwright writes screenshots, traces, and videos beneath the test output directory configured for the run. If you have not changed that setting, the directory is typically test-results. The HTML reporter and other configured reporters determine how attachments are displayed; open the report rather than searching only for a manually chosen filename.
To make locations predictable in CI, set a consistent output directory in your Playwright configuration and publish that directory as a CI artifact. Do not assume a local absolute path will exist on another worker. Parallel workers may create separate result subdirectories for the same test name.
Run and inspect a failure
- Install Playwright and its browser binaries in the project as usual.
- Add
screenshot: 'only-on-failure'underuse, or add the custom hook shown above. - Run the test command used by your project, for example
npx playwright test. - When a test fails, note the output directory reported by the runner.
- Open the generated HTML report (if enabled) or inspect the published test-results artifact in CI.
- Use the image with the error message, trace, console output, and network information; the screenshot shows visual state but does not replace those diagnostics.
Troubleshoot missing or unhelpful screenshots
No image is produced
- Confirm the setting is nested under
useand that the configuration file is the one used by the command. - Check whether the test actually failed. With
only-on-failure, passing tests intentionally produce no image. - Verify that the reporter or CI job publishes the configured output directory.
- If a custom hook is used, ensure the hook is imported or declared in a file loaded by the test run.
The screenshot shows the wrong page
Capture immediately after the failing action, before navigation, cleanup, or a fixture teardown changes the DOM. A custom page.screenshot() call is preferable to an automatic end-of-test image when timing is critical.
Rank #4
- 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
The image is cropped
Use fullPage: true for a complete scrollable document. If the page uses a virtualized list, content outside the viewport may not exist in the DOM; screenshotting cannot capture elements the application has not rendered.
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 →Attachments are not visible in the report
Make sure the attachment has a correct MIME type such as image/png, and open the report generated by the configured reporter. In CI, upload the test output directory after the test command completes.
Retries create too many files
Switch automatic capture to on-first-failure, or use a custom hook that names and attaches only the evidence you need. Keep retries when they reveal flakiness, but avoid collecting identical full-page images on every attempt.
The hook throws because the page is unavailable
Use the hook while the page fixture is alive, as in afterEach. If a browser crash or navigation failure makes the page unusable, rely on the automatic artifact and other diagnostics rather than trying to call methods on a closed page.
Or skip the browser setup
ScreenshotNeo provides a website screenshot API and MCP server when you need a clean image of a URL outside a Playwright test. One GET request returns PNG, JPEG, WebP, or PDF. 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 turned off. Bot checks or CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed, and each response reports the page verdict and billing status in X-Page-Verdict and X-Billed headers. Its MCP tools—take_screenshot, get_page_info, and capture_pdf—let Claude, Cursor, or another MCP client request captures.
Use the ScreenshotNeo documentation for the complete parameter list. A direct call looks like this:
Best Value
- 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.
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
Equivalent 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)
Equivalent 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 supports full-page and element captures, device presets and custom viewports, retina scale, dark mode, PDFs with paper and page-range controls, custom CSS and JavaScript, clicks, waits, ad and tracker blocking, headers, cookies, user agents, authorization, timezone, geolocation, transparent backgrounds, resizing, chosen cache TTLs, signed image links, asynchronous webhooks, bulk capture of up to 100 URLs per call, usage data, and an OpenAPI specification. Parameter names used by other screenshot APIs also work, which can simplify migration.
The Free plan includes 1,000 screenshots per month with no card. Paid plans start at $5 for 3,000 screenshots; Growth is $15 for 15,000, Pro $39 for 60,000, Scale $99 for 250,000, and Business $249 for 1,000,000. Yearly billing provides two months free, and every feature is included on every plan. Sign up free to get 1,000 screenshots a month without a card.
Frequently Asked Questions
Can I save a screenshot to a specific local filename?
Yes. Call page.screenshot({ path: 'failure.png' }), then pass that path to testInfo.attach() if you also want it shown as a test artifact.
Free tools Windows power users keep installed
One-click scans. No signup required.
Does an automatic screenshot include the browser console or network log?
No. It is an image of the page. Collect console, network, trace, or video artifacts separately when diagnosing the failure.
Should I use on-first-failure with retries?
Use it when one image per test is sufficient. Keep only-on-failure when comparing each failed attempt is important for flaky-test diagnosis.
Can a screenshot be attached to one step instead of the whole test?
Yes. Call step.attach() inside the test.step callback; this attributes the image to that step rather than to the test-level attachment list.
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.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.

