Skip to main content

Diagnostics and artifacts

A failing browser test shows what the browser saw at the failure. ProtoTest captures that automatically and attaches it to the test, where your runner and the ProtoTrace viewer both show it.

web.click · LoginPage.Form.Submit # FAILED (WebActionabilityException)
├─ web.backend.execute · playwright · click # the native driver call
├─ web-{session}-{element}-{n}-failure.png # full-page screenshot
├─ web-{session}-{element}-{n}-page.html # page HTML
└─ web-{session}-{element}-{n}-location.txt # URL and title

Open what the test left: the .prototrace archive (see Where it lands and how to open it), or the screenshots and page HTML in the runner output next to the exception.

On any failed operation​

When an action or assertion fails, the backend captures the page at that moment:

ArtifactFile
Screenshot (full page)web-{session}-{element}-{n}-failure.png
Page HTMLweb-{session}-{element}-{n}-page.html
Location (URL and title)web-{session}-{element}-{n}-location.txt

ProtoTest lowercases the name parts and replaces anything but letters and digits with -. It replaces {element} with the operation name when the failure has no element. It numbers repeats with a per-test sequence, so a failure repeated on the same element keeps both sets of artifacts. Captures run in order screenshot, DOM, location.

A hand-written backend produces the same artifacts by calling WebFailureArtifacts.CaptureAsync(…) in ProtoTest.Web, and reports the same resolution and actionability wording through WebBackendErrors; both are part of the backend-neutral building blocks.

Capturing never replaces the original error. Each artifact registers on its own, so one failing attachment does not drop the rest. If capture itself fails, you'll see a web.diagnostics.artifact_failed entry, or web.diagnostics.failed when the backend produced no attachments at all, and still get the real exception.

Captured downloads​

WebSession.DownloadAsync (and its WebPage shortcut) also registers the file the browser downloaded as a test attachment, named web-{session}-download-{n}-{file}: the session and stem are sanitized, the sequence keeps two downloads of the same name apart, and the extension is kept so the file stays openable. The media type is guessed from the extension. The attachment reaches your runner's output and the .prototrace archive like any other; a download that cannot be attached is traced as web.download.attachment_failed and the file is still returned to the test. Selenium fails the call with WebBackendCapabilityException before the trigger runs, because the WebDriver protocol has no download API.

Playwright traces​

Playwright's own trace, a timeline with DOM snapshots you can open in the Playwright Trace Viewer, is recorded while the test runs and kept according to TraceRetention:

ValueKeeps the trace
OnWebFailure (default)only when a web operation failed
Alwaysfor every test
Offnever; tracing isn't started

The kept trace is attached as playwright-{session}-trace.zip with content type application/vnd.microsoft.playwright.trace+zip; a capture failure is traced as web.playwright.trace_failed and never replaces the test's own error.

With CorrelateTraceGroups on (the default), each ProtoTest operation is a named group in the Playwright trace, [correlationId] [session] {name}, so the two timelines line up. Grouping is re-entrant: an operation nested inside another on the same session, such as a WaitUntilAsync predicate that reads an element, joins its caller's group instead of blocking on it. Groups are serialized by a semaphore, are skipped entirely when TraceRetention = Off, and a failure to start or end a group is traced as web.playwright.correlation_failed.

Browser signals​

These go into ProtoTrace as events on the test, parented to the active operation via web.correlation_id:

OptionTrace entry
ConsoleCapture (WarningsAndErrors by default)web.browser.console carrying browser.console.type and browser.console.text, truncated at 4096 characters
CapturePageErrorsweb.browser.page_error carrying browser.error.message, truncated at 4096 characters
CaptureRequestFailuresweb.browser.request_failed carrying http.method, http.url without query or fragment, and browser.request.failure, truncated at 4096 characters

Selenium diagnostics​

Selenium has no equivalent trace format, so ProtoTest writes its own selenium-{session}-diagnostics.json, kept according to DiagnosticTraceRetention (same three values, same default). The payload schema is format = "prototest.selenium.diagnostics.v1":

Field
format"prototest.selenium.diagnostics.v1"
startedAtUtc, completedAtUtcthe session's window
driverTypethe concrete driver type
url, titlethe final location, best-effort
entries[]every actionability attempt: TimestampUtc, Operation, ComponentPath, Element, Locator, Attempt, Outcome, Observation and ElapsedMilliseconds

When a Selenium click "randomly" fails, this is where you find out it was covered by a toast for 4.8 seconds. A failure while writing the attachment is traced as web.diagnostics.artifact_failed. The timeline exists only as this one JSON attachment; there is no second report system.

What the trace records for every operation​

Every web operation is a trace entry carrying web.backend and web.session; element operations add web.component, web.element, web.locator and web.component.roots:

KindForExtra attributes
web.navigateOpenAsyncweb.address
web.clickClickAsync
web.fillFillAsyncweb.value = [REDACTED], web.value.length
web.checkCheckAsync / UncheckAsync
web.select_optionSelectOptionAsyncweb.option
web.pressPressAsyncweb.key
web.countCountAsync
web.read_text / web.read_valueTextAsync / ValueAsync
web.is_visible / web.is_enabled / web.is_checkedthe state reads
assert.webevery Should/ShouldNot assertionweb.expectation, web.assert.negated, web.assert.timeout
web.flowflowsweb.flow.step_count
web.wait.untilWaitUntilAsyncweb.expectation, web.wait.timeout
web.downloadDownloadAsyncweb.download.requested_name, web.download.name, web.download.media_type, web.download.size; registers the file as an attachment
web.waitwait conditionsweb.wait.timing, web.wait.condition, web.wait.timeout, web.wait.last_observed, web.operation
web.loginlogin, setup phaseweb.login.persona, web.login.strategy
web.session.initializethe browser startingweb.backend
web.session.completethe session closing, teardown phaseweb.backend

Inside each parent operation, a child web.backend.execute named {backend} · {kind} carries web.correlation_id, the phase, the outcome and any failure; it is the link between a semantic operation and the native driver call.

Coverage observations are the other half of the trace: web.page.visited, web.page.verified and web.page.available, each with web.session and web.page.source (navigate, assert, vue-router or aspnetcore). See Page coverage.

Other event kinds worth knowing when you read a trace: web.page.discovery.failed (Vue route discovery), web.page.inventory.failed (in-process ASP.NET Core inventory), web.playwright.correlation_failed / web.playwright.trace_failed, and web.diagnostics.failed / web.diagnostics.artifact_failed / web.download.attachment_failed.

When artifacts are finalised​

Web sessions complete during teardown in reverse order, after normal teardown hooks but before attachments are published and before the browser is disposed. The Playwright trace and Selenium diagnostics are written at that point, and a failure is recorded on the session's web.session.complete entry and aggregated into a teardown failure. That ordering is what guarantees the native trace and diagnostics make it into the runner's output and the .prototrace archive.

Where it lands and how to open it​

Run the failing test, then open what it left:

  • The .prototrace archive lands at TestResults/prototest-{runId}.prototrace relative to the test process's working directory (usually the test project's bin/<config>/<tfm>), unless ConfigureTracing set OutputPath. Drop it on the ProtoTrace viewer or read it from the terminal with prototest summary <file> (ProtoTrace).
  • Screenshots, page HTML, location files, the Playwright trace and the Selenium diagnostics are registered as test attachments: NUnit, MSTest, xUnit v3 and TUnit show them in their own output, while xUnit v2 writes each artifact to a file and prints the path to the console (runner limits).
  • The trace also records every artifact on the failing operation, so the viewer's failure view shows them next to the exception even when the runner's output was lost.

Next​