Class LaunchOptions
- Namespace
- PuppeteerSharp
- Assembly
- PuppeteerSharp.dll
Options for launching the Chrome/ium browser.
public class LaunchOptions : IBrowserOptions, IConnectionOptions
- Inheritance
-
LaunchOptions
- Implements
Properties
AcceptInsecureCerts
Whether to ignore HTTPS errors during navigation. Defaults to false.
public bool AcceptInsecureCerts { get; set; }
Property Value
Args
Additional arguments to pass to the browser instance. List of Chromium flags can be found here.
public string[] Args { get; set; }
Property Value
- string[]
Browser
The browser to be used (Chrome, Chromium, Firefox).
public SupportedBrowser Browser { get; set; }
Property Value
Channel
Chrome Release Channel.
public ChromeReleaseChannel? Channel { get; set; }
Property Value
DefaultViewport
Gets or sets the default Viewport.
public ViewPortOptions DefaultViewport { get; set; }
Property Value
- ViewPortOptions
The default Viewport.
Devtools
Whether to auto-open DevTools panel for each tab. If this option is true, the headless option will be set false.
public bool Devtools { get; set; }
Property Value
DumpIO
Whether to pipe browser process stdout and stderr into process.stdout and process.stderr. Defaults to false.
public bool DumpIO { get; set; }
Property Value
EnqueueAsyncMessages
Affects how responses to SendAsync(string, object, bool, CommandOptions) are returned to the caller. If true
(default), the
response is delivered to the caller on its own thread; otherwise, the response is delivered the same way MessageReceived
events are raised.
public bool EnqueueAsyncMessages { get; set; }
Property Value
Remarks
This should normally be set to true
to support applications that aren't async
"all the way up"; i.e., the application
has legacy code that is not async which makes calls into PuppeteerSharp. If you experience issues, or your application is not mixed sync/async use, you
can set this to false
(default).
EnqueueTransportMessages
If not PuppeteerSharp.Transport is set this will be use to determine is the default WebSocketTransport will enqueue messages.
public bool EnqueueTransportMessages { get; set; }
Property Value
Remarks
It's set to true
by default because it's the safest way to send commands to Chromium.
Setting this to false
proved to work in .NET Core but it tends to fail on .NET Framework.
Env
Specify environment variables that will be visible to browser. Defaults to Environment variables.
public IDictionary<string, string> Env { get; }
Property Value
ExecutablePath
Path to a Chromium or Chrome executable to run instead of bundled Chromium. If executablePath is a relative path, then it is resolved relative to current working directory.
public string ExecutablePath { get; set; }
Property Value
ExtraPrefsFirefox
Additional preferences that can be passed when launching with Firefox.
public Dictionary<string, object> ExtraPrefsFirefox { get; set; }
Property Value
Headless
Whether to run browser in headless mode. Defaults to true unless the devtools option is true. If you need to run using the old headless mode, set HeadlessMode this to Shell.
public bool Headless { get; set; }
Property Value
HeadlessMode
Whether to run browser in headless mode. Defaults to true unless the devtools option is true.
public HeadlessMode HeadlessMode { get; set; }
Property Value
IgnoreDefaultArgs
If true
, then do not use GetDefaultArgs(LaunchOptions).
Dangerous option; use with care. Defaults to false
.
public bool IgnoreDefaultArgs { get; set; }
Property Value
IgnoredDefaultArgs
if IgnoreDefaultArgs is set to false
this list will be used to filter GetDefaultArgs(LaunchOptions).
public string[] IgnoredDefaultArgs { get; set; }
Property Value
- string[]
LogProcess
Logs process counts after launching chrome and after exiting.
public bool LogProcess { get; set; }
Property Value
ProtocolTimeout
Timeout setting for individual protocol (CDP) calls. Defaults to 180_000.
public int ProtocolTimeout { get; set; }
Property Value
SlowMo
Slows down Puppeteer operations by the specified amount of milliseconds. Useful so that you can see what is going on.
public int SlowMo { get; set; }
Property Value
TargetFilter
Callback to decide if Puppeteer should connect to a given target or not.
public Func<Target, bool> TargetFilter { get; set; }
Property Value
Timeout
Maximum time in milliseconds to wait for the browser instance to start. Defaults to 30000 (30 seconds). Pass 0 to disable timeout.
public int Timeout { get; set; }
Property Value
TransportFactory
Optional factory for IConnectionTransport implementations.
public TransportFactory TransportFactory { get; set; }
Property Value
UserDataDir
Path to a User Data Directory.
public string UserDataDir { get; set; }
Property Value
WebSocketFactory
Optional factory for WebSocket implementations. If PuppeteerSharp.Transport is set this property will be ignored.
public WebSocketFactory WebSocketFactory { get; set; }
Property Value
Remarks
If you need to run Puppeteer-Sharp on Windows 7, you can use WebSocketFactory to inject System.Net.WebSockets.Client.Managed.
WebSocketFactory = async (uri, socketOptions, cancellationToken) => { var client = SystemClientWebSocket.CreateClientWebSocket(); if (client is System.Net.WebSockets.Managed.ClientWebSocket managed) { managed.Options.KeepAliveInterval = TimeSpan.FromSeconds(0); await managed.ConnectAsync(uri, cancellationToken); } else { var coreSocket = client as ClientWebSocket; coreSocket.Options.KeepAliveInterval = TimeSpan.FromSeconds(0); await coreSocket.ConnectAsync(uri, cancellationToken); }
return client;
},