ConnectOptions
Namespace: PuppeteerSharp
public class ConnectOptions : IBrowserOptions, IConnectionOptionsOptions for connecting to an existing browser.
Inheritance: object
Implements: IBrowserOptions, IConnectionOptions
Properties
Section titled “Properties”AcceptInsecureCerts
Section titled “AcceptInsecureCerts”public bool AcceptInsecureCerts { get; set; }Whether to ignore HTTPS errors during navigation. Defaults to false.
Value: bool
Allowlist
Section titled “Allowlist”public string[] Allowlist { get; set; }A list of URL patterns to allow. When set, the browser can only access URLs matching these patterns.
Value: string[]
<p> Requires Chrome 149+. </p> <p> This option allows you to restrict the browser from accessing any URLs except for those that match the patterns in the allowlist. It uses the standard <a href=“https://urlpattern.spec.whatwg.org/">URLPattern</a> API to match URLs. </p> <p> When connecting to an existing browser, Puppeteer will silently detach from any already open targets that violate the patterns. </p> <p> For any network requests made by the browser (including navigations and subresources like images or scripts), the request will fail with an error if the URL does not match any pattern in the allowlist. </p> <p> Currently only supported for CDP connections. </p> <p> Cannot be used along with BlockList. </p>
Example
Pattern to allow a specific domain: *://example.com/*
Pattern to allow all subdomains: *://*.example.com/*.
BlockList
Section titled “BlockList”public string[] BlockList { get; set; }A list of URL patterns to block.
Value: string[]
<p> This option allows you to restrict the browser from accessing specific URLs or origins. It uses the standard <a href=“https://urlpattern.spec.whatwg.org/">URLPattern</a> API to match URLs. </p> <p> When connecting to an existing browser, Puppeteer will silently detach from any already open targets that violate the patterns. </p> <p> For any network requests made by the browser (including navigations and subresources like images or scripts), the request will fail with an error if the URL matches a blocked pattern. </p> <p> Currently only supported for CDP connections. </p> <p> Cannot be used along with Allowlist. </p>
Example
Pattern to block a specific domain: *://example.com/*
Pattern to block all subdomains: *://*.evil.com/*.
BrowserURL
Section titled “BrowserURL”public string BrowserURL { get; set; }A browser url to connect to, in format http://${host}:${port}.
Use interchangeably with browserWSEndpoint to let Puppeteer fetch it from <a href=“https://chromedevtools.github.io/devtools-protocol/#how-do-i-access-the-browser-target">metadata endpoin</a>.
Value: string
BrowserWSEndpoint
Section titled “BrowserWSEndpoint”public string BrowserWSEndpoint { get; set; }A browser websocket endpoint to connect to.
Value: string
DefaultViewport
Section titled “DefaultViewport”public ViewPortOptions DefaultViewport { get; set; }Gets or sets the default Viewport.
Value: ViewPortOptions — The default Viewport.
EnqueueAsyncMessages
Section titled “EnqueueAsyncMessages”public bool EnqueueAsyncMessages { get; set; }Affects how responses to 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.
Value: bool
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
Section titled “EnqueueTransportMessages”public bool EnqueueTransportMessages { get; set; }If not PuppeteerSharp.Transport is set this will be use to determine is the default WebSocketTransport will enqueue messages.
Value: bool
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.
HandleDevToolsAsPage
Section titled “HandleDevToolsAsPage”public bool HandleDevToolsAsPage { get; set; }Whether to handle the DevTools windows as pages in Puppeteer. Supported only in Chrome with CDP.
Value: bool
Headers
Section titled “Headers”[Obsolete("Use WsOptions.Headers via ConnectOptions.WsOptions instead. When both are set, WsOptions.Headers wins.")]public Dictionary<string, string> Headers { get; set; }Headers that should be sent with connection-related HTTP and WebSocket requests.
Value: Dictionary<string, string>
InitAction
Section titled “InitAction”public Action<IBrowser> InitAction { get; set; }Optional callback to initialize properties as soon as the IBrowser instance is created, i.e., set up event handlers.
Value: Action<IBrowser>
IssuesEnabled
Section titled “IssuesEnabled”public bool IssuesEnabled { get; set; }Experimental setting to disable monitoring issue events by default.
Value: bool
NetworkEnabled
Section titled “NetworkEnabled”public bool NetworkEnabled { get; set; }Experimental setting to disable monitoring network events by default. When
set to false, parts of Puppeteer that depend on network events would not
work such as IRequest and IResponse.
Value: bool
Protocol
Section titled “Protocol”public ProtocolType Protocol { get; set; }The protocol to use for browser communication. Defaults to Cdp. Set to WebdriverBiDi to use WebDriver BiDi. Firefox always uses WebDriver BiDi regardless of this setting.
Value: ProtocolType
ProtocolTimeout
Section titled “ProtocolTimeout”public int ProtocolTimeout { get; set; }Timeout setting for individual protocol (CDP) calls. Defaults to 180_000.
Value: int
SlowMo
Section titled “SlowMo”public int SlowMo { get; set; }Slows down Puppeteer operations by the specified amount of milliseconds. Useful so that you can see what is going on.
Value: int
TargetFilter
Section titled “TargetFilter”public Func<Target, bool> TargetFilter { get; set; }Callback to decide if Puppeteer should connect to a given target or not.
Value: Func<Target, bool>
TransportFactory
Section titled “TransportFactory”public TransportFactory TransportFactory { get; set; }Optional factory for IConnectionTransport implementations.
Value: TransportFactory
WebSocketFactory
Section titled “WebSocketFactory”public WebSocketFactory WebSocketFactory { get; set; }Optional factory for WebSocket implementations. If PuppeteerSharp.Transport is set this property will be ignored.
Value: WebSocketFactory
WsOptions
Section titled “WsOptions”public WsOptions WsOptions { get; set; }Options for the WebSocket connection to the browser.
Value: WsOptions
Made with love by Dario Kondratiuk