Docs · API reference · Motus.Testing

BrowserFixture Class#

Manages a single browser instance for use in test fixtures. Call InitializeAsync(LaunchOptions) once (typically in assembly/collection setup), then create isolated contexts per test via NewContextAsync(ContextOptions). If the browser crashes or becomes unresponsive, the fixture automatically restarts Chrome so subsequent tests proceed against a fresh browser.

public sealed class BrowserFixture : System.IAsyncDisposable

Inheritance System.Object → BrowserFixture

Implements System.IAsyncDisposable

Properties#

Browser Property#

The launched browser instance.

public Motus.Abstractions.IBrowser Browser { get; }

Property Value#

IBrowser

Methods#

CloseContextAsync(IBrowserContext) Method#

Closes a context and releases its concurrency throttle slot. Always releases the slot even if close fails (browser crashed).

public System.Threading.Tasks.Task CloseContextAsync(Motus.Abstractions.IBrowserContext context);

Parameters#

context IBrowserContext

Returns#

System.Threading.Tasks.Task

InitializeAsync(LaunchOptions) Method#

Launches a browser instance with the given options, retrying on transient failures.

public System.Threading.Tasks.Task InitializeAsync(Motus.Abstractions.LaunchOptions? options=null);

Parameters#

options LaunchOptions

Returns#

System.Threading.Tasks.Task

NewContextAsync(ContextOptions) Method#

Creates a new isolated browser context. If a restart is in progress (due to a browser crash), callers block until the new browser is ready. The context throttle limits concurrent contexts to avoid overwhelming Chrome.

public System.Threading.Tasks.Task<Motus.Abstractions.IBrowserContext> NewContextAsync(Motus.Abstractions.ContextOptions? options=null);

Parameters#

options ContextOptions

Returns#

System.Threading.Tasks.Task<IBrowserContext>