Skip to content

Session

Namespace: E2E

public class Session : IAsyncDisposable

One isolated session: a browser context, or the app on a device. Holds Screen, App, Platform, and Browser. Upstream’s Session and SessionControls (core/launch.ts), over the port’s E2ESession.

Inheritance: object

Implements: IAsyncDisposable

Derived: Session<TFixtures>

View source

public App App { get; }

App lifecycle: open, restart, clear state, back, screenshot, recording.

Value: App

public Browser Browser { get; }

The browser fixture. Its members fail with UNSUPPORTED_CAPABILITY on an engine without a browser.

Value: Browser

public string Platform { get; }

The engine’s platform label: web, ios, android, or an engine’s own string.

Value: string

public Screen Screen { get; }

Semantic queries and the actions on their matches.

Value: Screen

public Task CloseAsync()

Ends the session. Idempotent. Throws an AggregateException of the failures closing found, such as a cleanup that did not finish. Upstream’s close.

Returns: Task

public ValueTask DisposeAsync()

Ends the session. Idempotent. Throws an AggregateException of the failures closing found, such as a cleanup that did not finish. Upstream’s close.

Returns: ValueTask

public Task<SessionState> SaveStateAsync(CancellationToken cancellationToken = default)

Captures the session’s state (cookies, storage, app data) in memory. Persist it only with ExportAsync(SessionStateKeyOptions). Upstream’s saveState.

Parameters

Name Type Description
cancellationToken CancellationToken

Returns: Task<SessionState>

public void SetDefaultTimeout(TimeSpan timeout)

The default timeout of operations started from now on: actions, waits, reads, and app opens and restarts. A running operation keeps the deadline it started with. Throws INVALID_ARGUMENT unless <code class=“paramref”>timeout</code> is positive and finite. Upstream’s setDefaultTimeout.

Parameters

Name Type Description
timeout TimeSpan