Class BrowserObservabilityRecorder
java.lang.Object
com.shaft.tools.io.internal.BrowserObservabilityRecorder
Thread-local browser network, console, and capability metadata recorder for SHAFT trace artifacts.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordActive network exchange handle.static final recordBrowser network exchange details recorded into the trace.static final recordRead-only snapshot of one observed network transaction, safe to hand to a caller outside this class (unlikeBrowserObservabilityRecorder.NetworkEvent, which stays private since it backs the mutable trace list). -
Method Summary
Modifier and TypeMethodDescriptionstatic voidclear()Clears current-thread browser observability state.static voidcollectConsole(org.openqa.selenium.WebDriver driver) Collects Selenium browser logs into the console trace section.static StringReturns and clears current-thread network observations as a HAR-like JSON document.Returns and clears current-thread warnings.static voidfinishNetwork(BrowserObservabilityRecorder.NetworkExchange exchange, org.openqa.selenium.remote.http.HttpResponse response, String failureReason) Finishes a network exchange and records a redacted trace event.static voidrecordConsole(String source, String level, String message, long timestamp) Records a browser console event for the current test thread.static voidRecords a browser network event for the current test thread.static voidrecordWarning(String source, String message) Records safe browser observability metadata for unsupported capabilities.snapshot()Returns a read-only, 1-based snapshot of the current thread's observed network transactions without draining them, so a caller can list transactions repeatedly (for example an MCP tool answering separate "list" and "get by id" requests) without racingFailureTraceReporter's end-of-test drain of the same thread-local state.startNetwork(org.openqa.selenium.remote.http.HttpRequest request) Starts a network exchange and copies the request body so downstream filters can still read it.
-
Method Details
-
startNetwork
public static BrowserObservabilityRecorder.NetworkExchange startNetwork(org.openqa.selenium.remote.http.HttpRequest request) Starts a network exchange and copies the request body so downstream filters can still read it.- Parameters:
request- browser HTTP request- Returns:
- exchange handle, or a disabled handle when trace network capture is disabled
-
finishNetwork
public static void finishNetwork(BrowserObservabilityRecorder.NetworkExchange exchange, org.openqa.selenium.remote.http.HttpResponse response, String failureReason) Finishes a network exchange and records a redacted trace event.- Parameters:
exchange- exchange handle returned fromstartNetwork(HttpRequest)response- browser HTTP response, ornullon failurefailureReason- safe failure reason
-
recordNetwork
Records a browser network event for the current test thread.- Parameters:
observation- network exchange details
-
collectConsole
public static void collectConsole(org.openqa.selenium.WebDriver driver) Collects Selenium browser logs into the console trace section.- Parameters:
driver- active driver, ornull
-
recordConsole
-
recordWarning
-
drainWarnings
-
snapshot
Returns a read-only, 1-based snapshot of the current thread's observed network transactions without draining them, so a caller can list transactions repeatedly (for example an MCP tool answering separate "list" and "get by id" requests) without racingFailureTraceReporter's end-of-test drain of the same thread-local state.- Returns:
- immutable snapshot of currently recorded network transactions, oldest first
-
drainNetworkHarJson
Returns and clears current-thread network observations as a HAR-like JSON document.- Returns:
- HAR-like network JSON
-
clear
public static void clear()Clears current-thread browser observability state.
-