Docs · API reference · Motus.Abstractions

IBrowser Interface#

Represents a browser instance. A browser can have multiple contexts.

public interface IBrowser : System.IAsyncDisposable

Implements System.IAsyncDisposable

Properties#

Contexts Property#

Gets all browser contexts.

System.Collections.Generic.IReadOnlyList<Motus.Abstractions.IBrowserContext> Contexts { get; }

Property Value#

System.Collections.Generic.IReadOnlyList<IBrowserContext>

IsConnected Property#

Gets whether the browser is connected.

bool IsConnected { get; }

Property Value#

System.Boolean

IsHealthy Property#

Gets whether the browser is connected and its process is alive. When the browser process is not owned, equivalent to IsConnected.

bool IsHealthy { get; }

Property Value#

System.Boolean

OwnsProcess Property#

Gets whether Motus started the browser process and is therefore responsible for ending it. False for a browser that was already running and was connected to.

bool OwnsProcess { get; }

Property Value#

System.Boolean

Version Property#

Gets the browser version string.

string Version { get; }

Property Value#

System.String

Methods#

CloseAsync() Method#

Closes the browser and all its contexts. When the browser process is not owned, this disconnects instead: the browser keeps running and only this connection to it ends.

System.Threading.Tasks.Task CloseAsync();

Returns#

System.Threading.Tasks.Task

DisconnectAsync() Method#

Ends this connection to the browser and leaves the browser running. Never terminates the browser process, including one Motus started itself.

System.Threading.Tasks.Task DisconnectAsync();

Returns#

System.Threading.Tasks.Task

NewContextAsync(ContextOptions) Method#

Creates a new browser context.

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

Parameters#

options ContextOptions

Context options.

Returns#

System.Threading.Tasks.Task<IBrowserContext>
The new browser context.

NewPageAsync(ContextOptions) Method#

Creates a new page in a new browser context. Convenience method equivalent to creating a context and then a page.

System.Threading.Tasks.Task<Motus.Abstractions.IPage> NewPageAsync(Motus.Abstractions.ContextOptions? options=null);

Parameters#

options ContextOptions

Context options.

Returns#

System.Threading.Tasks.Task<IPage>
The new page.

Events#

Disconnected Event#

Raised when the browser is disconnected.

event EventHandler? Disconnected;

Event Type#

System.EventHandler