Skip to main content
Version: Next

PlaywrightBrowserPoolOptions

Hierarchy

Index

Properties

optionalinheritedcloseInactiveBrowserAfterSecs

closeInactiveBrowserAfterSecs?: number = 300

Browsers normally close immediately after their last page is processed. However, there could be situations where this does not happen. Browser Pool makes sure all inactive browsers are closed regularly, to free resources.

optionalconfiguration

configuration?: Configuration

Configuration to read the browser defaults from. Defaults to the global configuration.

optionalinheritedfingerprintOptions

fingerprintOptions?: FingerprintOptions

optionalheadless

headless?: boolean

Whether to run the browser in headless mode. Shorthand for launchContext.launchOptions.headless. Defaults to true, and can also be set via Configuration.

optionallaunchContext

launchContext?: PlaywrightLaunchContext

How to launch the browser: which Playwright browser type, proxy, user data dir, ...

optionalinheritedmaxOpenPagesPerBrowser

maxOpenPagesPerBrowser?: number = 20

Sets the maximum number of pages that can be open in a browser at the same time. Once reached, a new browser will be launched to handle the excess.

optionalinheritedoperationTimeoutSecs

operationTimeoutSecs?: number = 15

As we know from experience, async operations of the underlying libraries, such as launching a browser or opening a new page, can get stuck. To prevent BrowserPool from getting stuck, we add a timeout to those operations and you can configure it with this option.

optionalinheritedpostLaunchHooks

Post-launch hooks are executed as soon as a browser is launched. The hooks are called with two arguments: pageId: string and browserController: BrowserController To guarantee order of execution before other hooks in the same browser, the BrowserController methods cannot be used until the post-launch hooks complete. If you attempt to call await browserController.close() from a post-launch hook, it will deadlock the process. This API is subject to change.

optionalinheritedpostPageCloseHooks

postPageCloseHooks?: PostPageCloseHook<PlaywrightController>[]

Post-page-close hooks allow you to do page related clean up. The hooks are called with two arguments: pageId: string and browserController: BrowserController

optionalinheritedpostPageCreateHooks

postPageCreateHooks?: PostPageCreateHook<PlaywrightController, Page>[]

Post-page-create hooks are called right after a new page is created and all internal actions of Browser Pool are completed. This is the place to make changes to a page that you would like to apply to all pages. Such as injecting a JavaScript library into all pages. The hooks are called with two arguments: page: Page and browserController: BrowserController

optionalinheritedpreLaunchHooks

preLaunchHooks?: PreLaunchHook<LaunchContext<BrowserType<{}>, undefined | LaunchOptions, Browser, undefined | { acceptDownloads?: boolean; baseURL?: string; bypassCSP?: boolean; clientCertificates?: { cert?: Buffer<...>; certPath?: string; key?: Buffer<...>; keyPath?: string; origin: string; passphrase?: string; pfx?: Buffer<...>; pfxPath?: string }[]; colorScheme?: null | light | dark | no-preference; contrast?: null | no-preference | more; deviceScaleFactor?: number; extraHTTPHeaders?: {}; forcedColors?: null | active | none; geolocation?: { accuracy?: number; latitude: number; longitude: number }; hasTouch?: boolean; httpCredentials?: { origin?: string; password: string; send?: unauthorized | always; username: string }; ignoreHTTPSErrors?: boolean; isMobile?: boolean; javaScriptEnabled?: boolean; locale?: string; logger?: Logger; offline?: boolean; permissions?: string[]; proxy?: { bypass?: string; password?: string; server: string; username?: string }; recordHar?: { content?: omit | embed | attach; mode?: full | minimal; omitContent?: boolean; path: string; urlFilter?: string | RegExp }; recordVideo?: { dir?: string; showActions?: { duration?: ... | ...; fontSize?: ... | ...; position?: ... | ... | ... | ... | ... | ... | ... }; size?: { height: number; width: number } }; reducedMotion?: null | reduce | no-preference; screen?: { height: number; width: number }; serviceWorkers?: allow | block; storageState?: string | { cookies: { domain: string; expires: number; httpOnly: boolean; name: string; path: string; sameSite: ... | ... | ...; secure: boolean; value: string }[]; origins: { localStorage: ...[]; origin: string }[] }; strictSelectors?: boolean; timezoneId?: string; userAgent?: string; viewport?: null | { height: number; width: number } }, Page>>[]

Pre-launch hooks are executed just before a browser is launched and provide a good opportunity to dynamically change the launch options. The hooks are called with two arguments: pageId: string and launchContext: LaunchContext

optionalinheritedprePageCloseHooks

prePageCloseHooks?: PrePageCloseHook<PlaywrightController, Page>[]

Pre-page-close hooks give you the opportunity to make last second changes in a page that's about to be closed, such as saving a snapshot or updating state. The hooks are called with two arguments: page: Page and browserController: BrowserController

optionalinheritedprePageCreateHooks

prePageCreateHooks?: PrePageCreateHook<PlaywrightController, undefined | { acceptDownloads?: boolean; baseURL?: string; bypassCSP?: boolean; clientCertificates?: { cert?: Buffer<ArrayBufferLike>; certPath?: string; key?: Buffer<ArrayBufferLike>; keyPath?: string; origin: string; passphrase?: string; pfx?: Buffer<ArrayBufferLike>; pfxPath?: string }[]; colorScheme?: null | light | dark | no-preference; contrast?: null | no-preference | more; deviceScaleFactor?: number; extraHTTPHeaders?: {}; forcedColors?: null | active | none; geolocation?: { accuracy?: number; latitude: number; longitude: number }; hasTouch?: boolean; httpCredentials?: { origin?: string; password: string; send?: unauthorized | always; username: string }; ignoreHTTPSErrors?: boolean; isMobile?: boolean; javaScriptEnabled?: boolean; locale?: string; logger?: Logger; offline?: boolean; permissions?: string[]; proxy?: { bypass?: string; password?: string; server: string; username?: string }; recordHar?: { content?: omit | embed | attach; mode?: full | minimal; omitContent?: boolean; path: string; urlFilter?: string | RegExp }; recordVideo?: { dir?: string; showActions?: { duration?: number; fontSize?: number; position?: top-left | top | top-right | bottom-left | bottom | bottom-right }; size?: { height: number; width: number } }; reducedMotion?: null | reduce | no-preference; screen?: { height: number; width: number }; serviceWorkers?: allow | block; storageState?: string | { cookies: { domain: string; expires: number; httpOnly: boolean; name: string; path: string; sameSite: Strict | Lax | None; secure: boolean; value: string }[]; origins: { localStorage: { name: ...; value: ... }[]; origin: string }[] }; strictSelectors?: boolean; timezoneId?: string; userAgent?: string; viewport?: null | { height: number; width: number } }>[]

Pre-page-create hooks are executed just before a new page is created. They are useful to make dynamic changes to the browser before opening a page. The hooks are called with three arguments: pageId: string, browserController: BrowserController and pageOptions: object|undefined - This only works if the underlying BrowserController supports new page options. So far, new page options are only supported by PlaywrightController in incognito contexts. If the page options are not supported by BrowserController the pageOptions argument is undefined.

optionalinheritedretireBrowserAfterPageCount

retireBrowserAfterPageCount?: number = 100

Browsers tend to get bloated after processing a lot of pages. This option configures the maximum number of processed pages after which the browser will automatically retire and close. A new browser will launch in its place. The browser might be retired sooner if the connected Session is retired. You can change session retirement behavior using SessionPoolOptions.

optionalinheritedretireInactiveBrowserAfterSecs

retireInactiveBrowserAfterSecs?: number = 10

Browsers are marked as retired after they have been inactive for a certain amount of time. This option sets the interval at which the browsers are checked and retired if they are inactive.

Retired browsers are closed after all their pages are closed.

optionalinheriteduseFingerprints

useFingerprints?: boolean = true