Recommended Free Tools
To show a Selenium screenshot in a Microsoft test report, save the image before the browser closes and register it as an attachment to that test result. For MSTest, Microsoft documents TestContext.AddResultFile(fileName); for NUnit 3.7 or later, use TestContext.AddTestAttachment(fileName). Then publish the test results in a format and through a task supported by your TFS or Azure DevOps version. Writing a PNG to disk alone does not attach it to a report.
Choose the attachment route that fits your test setup
The right method depends on two things: the test framework and result format your tests produce, and whether the target is Azure DevOps Services, Azure DevOps Server, or an older TFS installation.
As an Amazon Associate I earn from qualifying purchases.
| Route | Where the screenshot appears | When to use it |
|---|---|---|
| Framework result attachment | On the individual test result | Use when your framework and result publisher support attachments. Microsoft’s guidance documents this path for MSTest and NUnit. |
| Build artifact | On the build’s Artifacts page, not as an attachment on the individual test result | Use when the image is saved but the result format or publishing task cannot carry it as a test attachment. |
| REST API attachment | On an individual test result or, separately, on the overall test run | Use when you need attachment placement through the API or the publishing route does not support the result format. |
Microsoft’s UI testing guidance describes screenshots as available on test results after results are published and documents the MSTest and NUnit registration calls. Its publishing-task documentation also distinguishes result formats and product versions, so do not assume attachment support is identical across TFS, Azure DevOps Server, and Azure DevOps Services.
Capture and register screenshots with MSTest
Expose the framework’s TestContext on the test class, capture the screenshot while the Selenium driver is still alive, and register the file path. The exact screenshot call depends on your Selenium language binding; the following C# pattern shows the ordering and attachment registration without assuming one universal driver implementation.
#1 Best Overall
- 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
using Microsoft.VisualStudio.TestTools.UnitTesting;
using OpenQA.Selenium;
using System;
using System.IO;
[TestClass]
public class CheckoutTests
{
public TestContext TestContext { get; set; }
[TestMethod]
public void Checkout_shows_confirmation()
{
IWebDriver driver = CreateDriver();
try
{
// Run the UI test using driver...
Assert.IsTrue(driver.Title.Contains("Confirmation"));
}
catch
{
var directory = Path.Combine(
Path.GetTempPath(), "ui-test-screenshots");
Directory.CreateDirectory(directory);
var fileName = Path.Combine(
directory, $"checkout-{Guid.NewGuid():N}.png");
((ITakesScreenshot)driver).GetScreenshot().SaveAsFile(fileName);
TestContext.AddResultFile(fileName);
throw;
}
finally
{
driver.Quit();
}
}
private IWebDriver CreateDriver()
{
throw new NotImplementedException("Create the driver for your project.");
}
}
Replace CreateDriver() with your project’s actual driver setup. The important sequence is: capture, save, register with AddResultFile, then let the test fail and tear down the session. Ensure the test agent can write to the chosen directory and that the file exists when the result is finalized. The exception is rethrown so the test remains failed rather than accidentally passing after diagnostic capture.
Capture and register screenshots with NUnit
For NUnit 3.7 or later, capture the file before teardown and register it with TestContext.AddTestAttachment. Confirm the installed NUnit version and the available overload before adopting the snippet; Selenium capture syntax also varies by binding.
Rank #2
- 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
using NUnit.Framework;
using OpenQA.Selenium;
using System;
using System.IO;
[TestFixture]
public class CheckoutTests
{
private IWebDriver driver;
[TearDown]
public void CaptureFailureAndCloseBrowser()
{
try
{
if (TestContext.CurrentContext.Result.Outcome.Status
== NUnit.Framework.Interfaces.TestStatus.Failed
&& driver is ITakesScreenshot screenshotDriver)
{
var directory = Path.Combine(
TestContext.CurrentContext.WorkDirectory, "screenshots");
Directory.CreateDirectory(directory);
var fileName = Path.Combine(
directory, $"checkout-{Guid.NewGuid():N}.png");
screenshotDriver.GetScreenshot().SaveAsFile(fileName);
TestContext.AddTestAttachment(fileName);
}
}
finally
{
driver?.Quit();
}
}
[Test]
public void Checkout_shows_confirmation()
{
// Create driver and run the UI test here.
}
}
Place failure capture in teardown only if the driver remains available there. If your test fixture disposes the driver earlier, capture in the test’s failure-handling path instead. Do not swallow test failures while collecting diagnostics.
Do these 3 things before closing this tab:
1Fix the driver behind crashes, sound loss and screen glitches2Clear out junk files and repair common Windows errors3Scan for outdated or missing drivers - takes under a minutePublish the results and check compatibility
- Produce a supported result file. For VSTest, the publishing task uses TRX. Microsoft documents the Publish Test Results v2 task as publishing results to Azure Pipelines or TFS, with published results visible in the pipeline Tests tab.
- Configure the publish task to find the result file. Set the task’s result format and file matching pattern to match the files your test run generates. A screenshot file is not itself a test result file; publish the TRX or other supported result output.
- Verify the specific test result. Open the failed test in the Tests view and check its attachments. If the result is present but the screenshot is missing, investigate format/task compatibility or use an artifact/API fallback below.
Microsoft’s UI-testing guidance describes limitations for some result formats in its documented publishing scenario. The current task reference notes that JUnit attachment support was added in Azure DevOps sprint 229 and is not available in Azure DevOps Server 2022.1 and lower. Check the documentation for the actual server and task version rather than applying a blanket rule to all TFS installations.
Rank #3
- 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.
Use a build artifact when test-level attachment is unsupported
If your publisher cannot carry the screenshot through with the test result, publish the screenshot directory as a build artifact. Microsoft documents that files published with Copy and Publish Build Artifacts are available on the build’s Artifacts page. This preserves access to the image but does not make it an attachment on the corresponding individual test result; retain a clear filename or folder structure to help map files back to tests.
Attach a screenshot with the Azure DevOps REST API
Attach to an individual test result
Azure DevOps Test API 7.1 provides a result-level attachment operation. You need the organization, project, test run ID, test case result ID, filename, and image bytes encoded as base64. The documented OAuth scope is vso.test_write.
Rank #4
- 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
POST https://dev.azure.com/{organization}/{project}/_apis/test/Runs/{runId}/Results/{testCaseResultId}/attachments?api-version=7.1
Content-Type: application/json
Authorization: Bearer {access-token}
{
"attachmentType": "GeneralAttachment",
"comment": "Selenium failure screenshot",
"fileName": "checkout-failure.png",
"stream": "{base64-encoded-file-bytes}"
}
On success, the operation returns an attachment reference. Obtain the correct run and result identifiers from your test publishing workflow; the route cannot associate an image with a result if those identifiers are wrong.
The Tool Desk
Outbyte Driver Updater FREEScan for outdated or missing drivers - takes under a minuteDriver Scan →Outbyte PC Repair FREERepair Windows errors before they cause bigger problemsFix Now →Attach to a run instead
A separate Test Results API operation attaches a file to the overall run rather than one test result. Its API version is 7.1-preview.1. Choose run-level placement only when the screenshot is intended to describe the run as a whole; for per-test failure diagnostics, use the result-level operation.
Best Value
- 【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.
Older on-premises TFS
The legacy TFS 2017 documentation gives a route of this form:
POST https://{instance}/DefaultCollection/{project}/_apis/test/runs/{run}/results/{result}/attachments?api-version={version}
Its request model includes stream, fileName, comment, and attachmentType. That legacy page lists TFS 2013, 2015, and 2017; it says TFS 2018 or later should use the Azure DevOps REST API reference. Confirm your configured collection, server version, and supported API version before adapting the route.
Troubleshoot missing or unusable screenshots
- The test report has no attachment: Saving a file is not enough. Register the path through the framework result mechanism, then confirm the result format and publisher support carrying attachments.
- The screenshot file is missing or empty: Check that capture runs before
Quit()or other teardown, that the test agent has write permission, and that the file exists before result finalization. - Only some test frameworks show screenshots: The documented registration examples are framework-specific. Verify the framework’s attachment API and the publishing task’s support for its output format.
- JUnit attachments fail on an on-premises server: Attachment support varies by Azure DevOps version; the task reference excludes Azure DevOps Server 2022.1 and lower for the newer JUnit support. Use a build artifact or REST attachment route if your installation cannot publish them.
- The API rejects the attachment: Verify the run/result IDs, project and organization, authorization scope, endpoint/API version, JSON field names, and base64 encoding of the raw file bytes.
- The screenshot is attached to the wrong level: Result-level and run-level routes are distinct. Use the result endpoint for an individual failure and the run endpoint only for a run-wide file.
Or skip the browser setup
If your goal is to capture a page rather than collect a screenshot from the Selenium test session, ScreenshotNeo offers a one-request screenshot API. It does not replace registering Selenium failure screenshots in TFS test results, but it can simplify standalone page captures and agent workflows.
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}`);
See the ScreenshotNeo API documentation for request options. Cookie banners are accepted or removed before capture, and newsletter popups and chat widgets are removed; those steps can be disabled. Bot checks, blank pages, timeouts, failed loads, and cache hits are not billed, with response headers identifying the page verdict and billing status. An MCP server offers screenshot and PDF tools for AI agents. The Free plan includes 1,000 screenshots a month with no card; paid plans start at $5 for 3,000. Every feature is available on every plan. Sign up for 1,000 free screenshots a month, with no card required.
Frequently Asked Questions
Does saving a Selenium screenshot automatically put it in the TFS report?
No. The image must be registered through a supported test-result attachment mechanism or uploaded through another route.
Can I attach one screenshot to a whole test run instead of a test result?
Yes. Azure DevOps has a separate run-level attachment operation, distinct from the result-level endpoint.
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.
Quick wins for a faster PC:
Repair Windows errors before they cause bigger problemsFix Now →Fix the driver behind crashes, sound loss and screen glitchesFind Drivers →




