Skip to main content
Version: 3.8

BrowserPoolHooks <BC, LC, PR>

Index

Properties

optionalpostLaunchHooks

postLaunchHooks?: PostLaunchHook<BC>[]

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.

optionalpostPageCloseHooks

postPageCloseHooks?: PostPageCloseHook<BC>[]

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

optionalpostPageCreateHooks

postPageCreateHooks?: PostPageCreateHook<BC, PR>[]

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

optionalpreLaunchHooks

preLaunchHooks?: PreLaunchHook<LC>[]

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

optionalprePageCloseHooks

prePageCloseHooks?: PrePageCloseHook<BC, PR>[]

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

optionalprePageCreateHooks

prePageCreateHooks?: PrePageCreateHook<BC, Parameters<BC[newPage]>[0]>[]

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.