Traces and HAR files
A trace records what a test did step by step: every Browser action with screenshots, DOM snapshots, console messages and network requests, grouped by the Robot Framework keywords that caused them. It is the most detailed way to find out why a test failed, especially on CI. A HAR file records only the network traffic.
Recording a trace
Section titled “Recording a trace”Start Electron Application and Start VS Code record a trace when they get tracing. It works as tracing of Browser’s New Context:
Truesaves the trace inbrowser/tracesin the output directory, named after the application’s context. Give a path to choose the name.- A path ending in
.zipsaves it there, and a folder saves it in that folder. Relative paths are relative to the output directory, and folders relative tobrowser/traces. - Without
tracing, the variable or environment variableROBOT_FRAMEWORK_BROWSER_TRACINGset toTruetraces every application and every context that Browser opens.
*** Settings ***Library Electron
*** Test Cases ***Traced Run Start Electron Application /opt/my-app/my-app tracing=True Click text=Say hello Close Electron ApplicationBrowser saves the trace when the application closes, through Close Electron Application, Close VS Code or Browser’s automatic closing. Open it with Browser’s command line tool, or drop the file on trace.playwright.dev:
rfbrowser show-trace results/browser/traces/trace_context=….zipRecording a HAR file
Section titled “Recording a HAR file”record_har records the network traffic of the windows into a HAR file. It works as recordHar of New Context: a dictionary with the path of the file and optionally omitContent. A relative path is relative to the output directory. Playwright writes the file when the application closes.
A HAR file holds what the windows load: their pages, scripts and requests, and in VS Code the workbench’s resources and the content of webviews. Requests that the main process or VS Code’s extension host make do not go through a window, so they are not in it. An extension’s own HTTP requests, for example, run in the extension host.
Things to know
Section titled “Things to know”- Size: a trace contains screenshots and snapshots of every action and grows with the length of the test. For long suites, trace only where you need it, or use Browser’s
auto_delete_passed_tracingto keep only the traces of failed tests.