Class WebRecorderClient
Spawns the Node.js web recorder (node bin/record.mjs --stream) as a child process
and translates its JSON stdout stream into RecordedEvent objects.
Approach: direct child process (option a) — Studio spawns Node and reads JSONL from stdout. One JSON line is emitted per event. The C# side parses each line and raises EventCaptured. StopAsync() sends SIGINT (Process.Kill on Windows) and waits for the process to exit.
public sealed class WebRecorderClient : IDisposable
- Inheritance
-
WebRecorderClient
- Implements
- Inherited Members
Properties
CurrentEvents
Live snapshot of events captured so far (thread-safe).
public IReadOnlyList<RecordedEvent> CurrentEvents { get; }
Property Value
Methods
Dispose()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
public void Dispose()
ParseJsonLine(string)
Parses a single JSON line from the Node recorder into a RecordedEvent. The Node shape is:
{ "kind": "click", "timestamp": "...", "element": { "testId": "...", "role": "...", ... }, "value": null, "key": null, "url": null }
Exposed as public so that unit tests can exercise the parser directly
without spawning a Node process.
public static RecordedEvent? ParseJsonLine(string line)
Parameters
linestring
Returns
StartAsync(string, string, CancellationToken)
Starts the Node recorder process and begins streaming events.
public Task StartAsync(string url, string browserType, CancellationToken ct = default)
Parameters
urlstringInitial URL to navigate to.
browserTypestringBrowser type: chromium, firefox, or webkit.
ctCancellationTokenCancellation token (cancellation kills the child process).
Returns
StopAsync()
Kills the Node recorder process, waits for it to exit, and returns all captured events.
public Task<IReadOnlyList<RecordedEvent>> StopAsync()
Returns
Events
EventCaptured
Raised on a background thread for each event emitted by the Node recorder.
public event Action<RecordedEvent>? EventCaptured