Table of Contents

Class BrowserTypeLaunchPersistentContextOptions

Namespace
Microsoft.Playwright
Assembly
Microsoft.Playwright.dll
public class BrowserTypeLaunchPersistentContextOptions
Inheritance
BrowserTypeLaunchPersistentContextOptions
Inherited Members

Constructors

BrowserTypeLaunchPersistentContextOptions()

public BrowserTypeLaunchPersistentContextOptions()

BrowserTypeLaunchPersistentContextOptions(BrowserTypeLaunchPersistentContextOptions)

public BrowserTypeLaunchPersistentContextOptions(BrowserTypeLaunchPersistentContextOptions clone)

Parameters

clone BrowserTypeLaunchPersistentContextOptions

Properties

AcceptDownloads

Whether to automatically download all the attachments. Defaults to true where all the downloads are accepted.

[JsonPropertyName("acceptDownloads")]
public bool? AcceptDownloads { get; set; }

Property Value

bool?

Args

Additional arguments to pass to the browser instance. The list of Chromium flags can be found here.

[JsonPropertyName("args")]
public IEnumerable<string>? Args { get; set; }

Property Value

IEnumerable<string>

Remarks

Use custom browser args at your own risk, as some of them may break Playwright functionality.

BaseURL

When using GotoAsync(string, PageGotoOptions?), RouteAsync(string, Action<IRoute>, PageRouteOptions?), WaitForURLAsync(string, PageWaitForURLOptions?), RunAndWaitForRequestAsync(Func<Task>, string, PageRunAndWaitForRequestOptions?), or RunAndWaitForResponseAsync(Func<Task>, string, PageRunAndWaitForResponseOptions?) it takes the base URL in consideration by using the URL() constructor for building the corresponding URL. Unset by default. Examples:

  • baseURL: http://localhost:3000 and navigating to /bar.html results in http://localhost:3000/bar.html
  • baseURL: http://localhost:3000/foo/ and navigating to ./bar.html results in http://localhost:3000/foo/bar.html
  • baseURL: http://localhost:3000/foo (without trailing slash) and navigating to ./bar.html results in http://localhost:3000/bar.html
[JsonPropertyName("baseURL")]
public string? BaseURL { get; set; }

Property Value

string

BypassCSP

Toggles bypassing page's Content-Security-Policy. Defaults to false.

[JsonPropertyName("bypassCSP")]
public bool? BypassCSP { get; set; }

Property Value

bool?

Channel

Browser distribution channel. Supported values are "chrome", "chrome-beta", "chrome-dev", "chrome-canary", "msedge", "msedge-beta", "msedge-dev", "msedge-canary". Read more about using Google Chrome and Microsoft Edge.

[JsonPropertyName("channel")]
public string? Channel { get; set; }

Property Value

string

ChromiumSandbox

Enable Chromium sandboxing. Defaults to false.

[JsonPropertyName("chromiumSandbox")]
public bool? ChromiumSandbox { get; set; }

Property Value

bool?

ColorScheme

Emulates 'prefers-colors-scheme' media feature, supported values are 'light', 'dark', 'no-preference'. See EmulateMediaAsync(PageEmulateMediaOptions?) for more details. Passing 'null' resets emulation to system defaults. Defaults to 'light'.

[JsonPropertyName("colorScheme")]
public ColorScheme? ColorScheme { get; set; }

Property Value

ColorScheme?

DeviceScaleFactor

Specify device scale factor (can be thought of as dpr). Defaults to 1. Learn more about emulating devices with device scale factor.

[JsonPropertyName("deviceScaleFactor")]
public float? DeviceScaleFactor { get; set; }

Property Value

float?

Devtools

**DEPRECATED** Use debugging tools instead.

**Chromium-only** Whether to auto-open a Developer Tools panel for each tab. If this option is true, the headless option will be set false.

[JsonPropertyName("devtools")]
[Obsolete]
public bool? Devtools { get; set; }

Property Value

bool?

DownloadsPath

If specified, accepted downloads are downloaded into this directory. Otherwise, temporary directory is created and is deleted when browser is closed. In either case, the downloads are deleted when the browser context they were created in is closed.

[JsonPropertyName("downloadsPath")]
public string? DownloadsPath { get; set; }

Property Value

string

Env

Specify environment variables that will be visible to the browser. Defaults to process.env.

[JsonPropertyName("env")]
public IEnumerable<KeyValuePair<string, string>>? Env { get; set; }

Property Value

IEnumerable<KeyValuePair<string, string>>

ExecutablePath

Path to a browser executable to run instead of the bundled one. If executablePath is a relative path, then it is resolved relative to the current working directory. Note that Playwright only works with the bundled Chromium, Firefox or WebKit, use at your own risk.

[JsonPropertyName("executablePath")]
public string? ExecutablePath { get; set; }

Property Value

string

ExtraHTTPHeaders

An object containing additional HTTP headers to be sent with every request. Defaults to none.

[JsonPropertyName("extraHTTPHeaders")]
public IEnumerable<KeyValuePair<string, string>>? ExtraHTTPHeaders { get; set; }

Property Value

IEnumerable<KeyValuePair<string, string>>

FirefoxUserPrefs

Firefox user preferences. Learn more about the Firefox user preferences at about:config.

[JsonPropertyName("firefoxUserPrefs")]
public IEnumerable<KeyValuePair<string, object>>? FirefoxUserPrefs { get; set; }

Property Value

IEnumerable<KeyValuePair<string, object>>

ForcedColors

Emulates 'forced-colors' media feature, supported values are 'active', 'none'. See EmulateMediaAsync(PageEmulateMediaOptions?) for more details. Passing 'null' resets emulation to system defaults. Defaults to 'none'.

[JsonPropertyName("forcedColors")]
public ForcedColors? ForcedColors { get; set; }

Property Value

ForcedColors?

Geolocation

[JsonPropertyName("geolocation")]
public Geolocation? Geolocation { get; set; }

Property Value

Geolocation

HandleSIGHUP

Close the browser process on SIGHUP. Defaults to true.

[JsonPropertyName("handleSIGHUP")]
public bool? HandleSIGHUP { get; set; }

Property Value

bool?

HandleSIGINT

Close the browser process on Ctrl-C. Defaults to true.

[JsonPropertyName("handleSIGINT")]
public bool? HandleSIGINT { get; set; }

Property Value

bool?

HandleSIGTERM

Close the browser process on SIGTERM. Defaults to true.

[JsonPropertyName("handleSIGTERM")]
public bool? HandleSIGTERM { get; set; }

Property Value

bool?

HasTouch

Specifies if viewport supports touch events. Defaults to false. Learn more about mobile emulation.

[JsonPropertyName("hasTouch")]
public bool? HasTouch { get; set; }

Property Value

bool?

Headless

Whether to run browser in headless mode. More details for Chromium and Firefox. Defaults to true unless the devtools option is true.

[JsonPropertyName("headless")]
public bool? Headless { get; set; }

Property Value

bool?

HttpCredentials

Credentials for HTTP authentication. If no origin is specified, the username and password are sent to any servers upon unauthorized responses.

[JsonPropertyName("httpCredentials")]
public HttpCredentials? HttpCredentials { get; set; }

Property Value

HttpCredentials

IgnoreAllDefaultArgs

If true, Playwright does not pass its own configurations args and only uses the ones from args. Dangerous option; use with care. Defaults to false.

[JsonPropertyName("ignoreAllDefaultArgs")]
public bool? IgnoreAllDefaultArgs { get; set; }

Property Value

bool?

IgnoreDefaultArgs

If true, Playwright does not pass its own configurations args and only uses the ones from args. Dangerous option; use with care.

[JsonPropertyName("ignoreDefaultArgs")]
public IEnumerable<string>? IgnoreDefaultArgs { get; set; }

Property Value

IEnumerable<string>

IgnoreHTTPSErrors

Whether to ignore HTTPS errors when sending network requests. Defaults to false.

[JsonPropertyName("ignoreHTTPSErrors")]
public bool? IgnoreHTTPSErrors { get; set; }

Property Value

bool?

IsMobile

Whether the meta viewport tag is taken into account and touch events are enabled. isMobile is a part of device, so you don't actually need to set it manually. Defaults to false and is not supported in Firefox. Learn more about mobile emulation.

[JsonPropertyName("isMobile")]
public bool? IsMobile { get; set; }

Property Value

bool?

JavaScriptEnabled

Whether or not to enable JavaScript in the context. Defaults to true. Learn more about disabling JavaScript.

[JsonPropertyName("javaScriptEnabled")]
public bool? JavaScriptEnabled { get; set; }

Property Value

bool?

Locale

Specify user locale, for example en-GB, de-DE, etc. Locale will affect navigator.language value, Accept-Language request header value as well as number and date formatting rules. Defaults to the system default locale. Learn more about emulation in our emulation guide.

[JsonPropertyName("locale")]
public string? Locale { get; set; }

Property Value

string

Offline

Whether to emulate network being offline. Defaults to false. Learn more about network emulation.

[JsonPropertyName("offline")]
public bool? Offline { get; set; }

Property Value

bool?

Permissions

A list of permissions to grant to all pages in this context. See GrantPermissionsAsync(IEnumerable<string>, BrowserContextGrantPermissionsOptions?) for more details. Defaults to none.

[JsonPropertyName("permissions")]
public IEnumerable<string>? Permissions { get; set; }

Property Value

IEnumerable<string>

Proxy

Network proxy settings.

[JsonPropertyName("proxy")]
public Proxy? Proxy { get; set; }

Property Value

Proxy

RecordHarContent

Optional setting to control resource content management. If omit is specified, content is not persisted. If attach is specified, resources are persisted as separate files and all of these files are archived along with the HAR file. Defaults to embed, which stores content inline the HAR file as per HAR specification.

[JsonPropertyName("recordHarContent")]
public HarContentPolicy? RecordHarContent { get; set; }

Property Value

HarContentPolicy?

RecordHarMode

When set to minimal, only record information necessary for routing from HAR. This omits sizes, timing, page, cookies, security and other types of HAR information that are not used when replaying from HAR. Defaults to full.

[JsonPropertyName("recordHarMode")]
public HarMode? RecordHarMode { get; set; }

Property Value

HarMode?

RecordHarOmitContent

Optional setting to control whether to omit request content from the HAR. Defaults to false.

[JsonPropertyName("recordHarOmitContent")]
public bool? RecordHarOmitContent { get; set; }

Property Value

bool?

RecordHarPath

Enables HAR recording for all pages into the specified HAR file on the filesystem. If not specified, the HAR is not recorded. Make sure to call CloseAsync(BrowserContextCloseOptions?) for the HAR to be saved.

[JsonPropertyName("recordHarPath")]
public string? RecordHarPath { get; set; }

Property Value

string

RecordHarUrlFilter

[JsonPropertyName("recordHarUrlFilter")]
public string? RecordHarUrlFilter { get; set; }

Property Value

string

RecordHarUrlFilterRegex

[JsonPropertyName("recordHarUrlFilterRegex")]
public Regex? RecordHarUrlFilterRegex { get; set; }

Property Value

Regex

RecordHarUrlFilterString

[JsonPropertyName("recordHarUrlFilterString")]
public string? RecordHarUrlFilterString { get; set; }

Property Value

string

RecordVideoDir

Enables video recording for all pages into the specified directory. If not specified videos are not recorded. Make sure to call CloseAsync(BrowserContextCloseOptions?) for videos to be saved.

[JsonPropertyName("recordVideoDir")]
public string? RecordVideoDir { get; set; }

Property Value

string

RecordVideoSize

Dimensions of the recorded videos. If not specified the size will be equal to viewport scaled down to fit into 800x800. If viewport is not configured explicitly the video size defaults to 800x450. Actual picture of each page will be scaled down if necessary to fit the specified size.

[JsonPropertyName("recordVideoSize")]
public RecordVideoSize? RecordVideoSize { get; set; }

Property Value

RecordVideoSize

ReducedMotion

Emulates 'prefers-reduced-motion' media feature, supported values are 'reduce', 'no-preference'. See EmulateMediaAsync(PageEmulateMediaOptions?) for more details. Passing 'null' resets emulation to system defaults. Defaults to 'no-preference'.

[JsonPropertyName("reducedMotion")]
public ReducedMotion? ReducedMotion { get; set; }

Property Value

ReducedMotion?

ScreenSize

Emulates consistent window screen size available inside web page via window.screen. Is only used when the viewport is set.

[JsonPropertyName("screen")]
public ScreenSize? ScreenSize { get; set; }

Property Value

ScreenSize

ServiceWorkers

Whether to allow sites to register Service workers. Defaults to 'allow'.

  • 'allow': Service Workers can be registered.
  • 'block': Playwright will block all registration of Service Workers.
[JsonPropertyName("serviceWorkers")]
public ServiceWorkerPolicy? ServiceWorkers { get; set; }

Property Value

ServiceWorkerPolicy?

SlowMo

Slows down Playwright operations by the specified amount of milliseconds. Useful so that you can see what is going on.

[JsonPropertyName("slowMo")]
public float? SlowMo { get; set; }

Property Value

float?

StrictSelectors

If set to true, enables strict selectors mode for this context. In the strict selectors mode all operations on selectors that imply single target DOM element will throw when more than one element matches the selector. This option does not affect any Locator APIs (Locators are always strict). Defaults to false. See ILocator to learn more about the strict mode.

[JsonPropertyName("strictSelectors")]
public bool? StrictSelectors { get; set; }

Property Value

bool?

Timeout

Maximum time in milliseconds to wait for the browser instance to start. Defaults to 30000 (30 seconds). Pass 0 to disable timeout.

[JsonPropertyName("timeout")]
public float? Timeout { get; set; }

Property Value

float?

TimezoneId

Changes the timezone of the context. See ICU's metaZones.txt for a list of supported timezone IDs. Defaults to the system timezone.

[JsonPropertyName("timezoneId")]
public string? TimezoneId { get; set; }

Property Value

string

TracesDir

If specified, traces are saved into this directory.

[JsonPropertyName("tracesDir")]
public string? TracesDir { get; set; }

Property Value

string

UserAgent

Specific user agent to use in this context.

[JsonPropertyName("userAgent")]
public string? UserAgent { get; set; }

Property Value

string

ViewportSize

Emulates consistent viewport for each page. Defaults to an 1280x720 viewport. Use ViewportSize.NoViewport to disable the consistent viewport emulation. Learn more about viewport emulation.

[JsonPropertyName("viewport")]
public ViewportSize? ViewportSize { get; set; }

Property Value

ViewportSize

Remarks

The ViewportSize.NoViewport value opts out from the default presets, makes viewport depend on the host window size defined by the operating system. It makes the execution of the tests non-deterministic.