Table of Contents

Class WebRecorderClient

Namespace
Cress.Studio.Services
Assembly
Cress.Studio.Core.dll

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

IReadOnlyList<RecordedEvent>

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

line string

Returns

RecordedEvent

StartAsync(string, string, CancellationToken)

Starts the Node recorder process and begins streaming events.

public Task StartAsync(string url, string browserType, CancellationToken ct = default)

Parameters

url string

Initial URL to navigate to.

browserType string

Browser type: chromium, firefox, or webkit.

ct CancellationToken

Cancellation token (cancellation kills the child process).

Returns

Task

StopAsync()

Kills the Node recorder process, waits for it to exit, and returns all captured events.

public Task<IReadOnlyList<RecordedEvent>> StopAsync()

Returns

Task<IReadOnlyList<RecordedEvent>>

Events

EventCaptured

Raised on a background thread for each event emitted by the Node recorder.

public event Action<RecordedEvent>? EventCaptured

Event Type

Action<RecordedEvent>