Skip to content

WebEngineOptions

Namespace: E2E.Engine

public sealed class WebEngineOptions

Options of the browser engine: how it drives the app.

Inheritance: object

View source

public WebBasicAuth? BasicAuth { get; init; }

Basic-auth credentials the browser answers a challenge with, wherever one is issued.

Value: WebBasicAuth

View source

public IBrowserProvider? Browser { get; init; }

Leases hosted browsers from a provider instead of launching one: the engine attaches over CDP the way Connect does, and adds the lifecycle Connect lacks. It asks the provider for a browser when one is needed and gives it back when its scope ends, on every exit path. A provider implies Chromium and cannot be combined with Connect. With Attempt scope the attempt rides a persistent context, with the limits of ReconnectEndpoint.

Value: IBrowserProvider

View source

public WebColorScheme? ColorScheme { get; init; }

The prefers-color-scheme every page reports from its first paint, to its @media rules and to matchMedia, as Playwright’s own colorScheme context option sets it. Defaults to the browser’s own. Browser.EmulateMediaAsync changes it for the rest of one attempt.

Value: WebColorScheme?

View source

public WebConnectOptions? Connect { get; init; }

Attach to a remote Chromium over CDP instead of launching a local one.

Value: WebConnectOptions

View source

public IReadOnlyDictionary<string, string>? Headers { get; init; }

Headers added to every request bound for the app’s host (the host of the session’s base URL). Requests to any other host never carry them, so a secret header stays with the app it unlocks. Names are case-insensitive and replace a header the page already sends under the same name. Routing every request turns the browser’s HTTP cache off.

Value: IReadOnlyDictionary<string, string>

View source

public bool? Headless { get; init; }

Runs Chromium without a window. When unset, E2E_HEADLESS=0 or false shows the window; headless otherwise.

Value: bool?

View source

public IReadOnlyList<WebInitScript>? InitScripts { get; init; }

Scripts every document runs before the page’s own, in every tab and frame, in order.

Value: IReadOnlyList<WebInitScript>

View source

public string? Locale { get; init; }

The locale every attempt’s context runs in, a BCP 47 tag such as de-DE: what navigator.language, Intl formatting, and the Accept-Language header report. Defaults to the browser’s own. An accept-language entry in Headers beside it is INVALID_CONFIG.

Value: string

View source

public WebReducedMotion? ReducedMotion { get; init; }

The prefers-reduced-motion every page reports from its first paint, as Playwright’s own reducedMotion context option sets it: Reduce lets an app’s own rule turn its animations off, so none races an assertion. Defaults to the browser’s own. Browser.EmulateMediaAsync changes it for the rest of one attempt.

Value: WebReducedMotion?

View source

public WebScreencastOptions? Screencast { get; init; }

How the engine’s own screencast records an attempt that records video, when the browser provider does not record it. Which attempts record is the config’s video.

Value: WebScreencastOptions

View source

public string TestIdAttribute { get; init; }

The attribute that carries an element’s test id: what GetByTestId resolves and TestId reports.

Value: string

View source

public string? TimezoneId { get; init; }

The IANA time zone every attempt’s context runs in, such as Europe/Berlin: what Date and Intl resolve local time against. Defaults to the machine’s.

Value: string

View source

public string? UserAgent { get; init; }

The User-Agent the browser sends and navigator.userAgent reports. Defaults to the browser’s own.

Value: string

View source

public WebViewport? Viewport { get; init; }

Initial viewport of every attempt’s page; default 1280 by 720. <a href=“https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null"&gt;null&lt;/a> emulates no size: the page fills the browser window, whatever size it has.

Value: WebViewport

View source