2020-05-12 15:30:13 +00:00
/ * *
2024-01-03 10:11:33 +00:00
* @license
* Copyright 2020 Google Inc .
* SPDX - License - Identifier : Apache - 2.0
2020-05-12 15:30:13 +00:00
* /
2021-02-16 09:39:31 +00:00
2023-11-14 14:21:24 +00:00
import type { BrowserConnectOptions } from '../common/ConnectOptions.js' ;
2023-09-26 16:24:24 +00:00
import type { Product } from '../common/Product.js' ;
2021-02-16 09:39:31 +00:00
2020-07-02 11:15:39 +00:00
/ * *
* Launcher options that only apply to Chrome .
*
* @public
* /
2021-02-16 09:39:31 +00:00
export interface BrowserLaunchArgumentOptions {
/ * *
* Whether to run the browser in headless mode .
2023-04-21 12:07:10 +00:00
*
* @remarks
2024-02-02 12:25:43 +00:00
*
* - ` true ` launches the browser in the
* { @link https : //developer.chrome.com/articles/new-headless/ | new headless}
* mode .
*
* - ` 'shell' ` launches
* { @link https : //developer.chrome.com/blog/chrome-headless-shell | shell}
* known as the old headless mode .
2023-04-21 12:07:10 +00:00
*
2023-03-29 13:27:29 +00:00
* @defaultValue ` true `
2021-02-16 09:39:31 +00:00
* /
2024-02-02 12:25:43 +00:00
headless? : boolean | 'shell' ;
2021-02-16 09:39:31 +00:00
/ * *
* Path to a user data directory .
2021-09-14 15:02:39 +00:00
* { @link https : //chromium.googlesource.com/chromium/src/+/refs/heads/main/docs/user_data_dir.md | see the Chromium docs}
2021-02-16 09:39:31 +00:00
* for more info .
* /
2020-05-12 15:30:13 +00:00
userDataDir? : string ;
2021-02-16 09:39:31 +00:00
/ * *
* Whether to auto - open a DevTools panel for each tab . If this is set to
2021-11-16 20:31:24 +00:00
* ` true ` , then ` headless ` will be forced to ` false ` .
2021-02-16 09:39:31 +00:00
* @defaultValue ` false `
* /
2020-05-12 15:30:13 +00:00
devtools? : boolean ;
2021-09-29 14:05:18 +00:00
/ * *
2023-03-30 11:54:00 +00:00
* Specify the debugging port number to use
2021-09-29 14:05:18 +00:00
* /
debuggingPort? : number ;
2021-02-16 09:39:31 +00:00
/ * *
* Additional command line arguments to pass to the browser instance .
* /
args? : string [ ] ;
2020-05-12 15:30:13 +00:00
}
2021-07-19 09:39:40 +00:00
/ * *
* @public
* /
2021-07-09 12:43:42 +00:00
export type ChromeReleaseChannel =
| 'chrome'
| 'chrome-beta'
| 'chrome-canary'
| 'chrome-dev' ;
2020-07-02 11:15:39 +00:00
/ * *
* Generic launch options that can be passed when launching any browser .
* @public
* /
2020-05-12 15:30:13 +00:00
export interface LaunchOptions {
2021-07-09 12:43:42 +00:00
/ * *
* Chrome Release Channel
* /
channel? : ChromeReleaseChannel ;
2021-02-16 09:39:31 +00:00
/ * *
* Path to a browser executable to use instead of the bundled Chromium . Note
* that Puppeteer is only guaranteed to work with the bundled Chromium , so use
* this setting at your own risk .
* /
2020-05-12 15:30:13 +00:00
executablePath? : string ;
2021-02-16 09:39:31 +00:00
/ * *
* If ` true ` , do not use ` puppeteer.defaultArgs() ` when creating a browser . If
* an array is provided , these args will be filtered out . Use this with care -
* you probably want the default arguments Puppeteer uses .
2023-03-29 13:27:29 +00:00
* @defaultValue ` false `
2021-02-16 09:39:31 +00:00
* /
2020-05-12 15:30:13 +00:00
ignoreDefaultArgs? : boolean | string [ ] ;
2021-02-16 09:39:31 +00:00
/ * *
* Close the browser process on ` Ctrl+C ` .
* @defaultValue ` true `
* /
2020-05-12 15:30:13 +00:00
handleSIGINT? : boolean ;
2021-02-16 09:39:31 +00:00
/ * *
* Close the browser process on ` SIGTERM ` .
* @defaultValue ` true `
* /
2020-05-12 15:30:13 +00:00
handleSIGTERM? : boolean ;
2021-02-16 09:39:31 +00:00
/ * *
* Close the browser process on ` SIGHUP ` .
* @defaultValue ` true `
* /
2020-05-12 15:30:13 +00:00
handleSIGHUP? : boolean ;
2021-02-16 09:39:31 +00:00
/ * *
* Maximum time in milliseconds to wait for the browser to start .
* Pass ` 0 ` to disable the timeout .
2023-03-29 13:27:29 +00:00
* @defaultValue ` 30_000 ` ( 30 seconds ) .
2021-02-16 09:39:31 +00:00
* /
2020-05-12 15:30:13 +00:00
timeout? : number ;
2021-02-16 09:39:31 +00:00
/ * *
* If true , pipes the browser process stdout and stderr to ` process.stdout `
* and ` process.stderr ` .
2023-03-29 13:27:29 +00:00
* @defaultValue ` false `
2021-02-16 09:39:31 +00:00
* /
2020-05-12 15:30:13 +00:00
dumpio? : boolean ;
2021-02-16 09:39:31 +00:00
/ * *
* Specify environment variables that will be visible to the browser .
* @defaultValue The contents of ` process.env ` .
* /
2020-05-12 15:30:13 +00:00
env? : Record < string , string | undefined > ;
2021-02-16 09:39:31 +00:00
/ * *
* Connect to a browser over a pipe instead of a WebSocket .
2023-03-29 13:27:29 +00:00
* @defaultValue ` false `
2021-02-16 09:39:31 +00:00
* /
2020-05-12 15:30:13 +00:00
pipe? : boolean ;
2021-02-16 09:39:31 +00:00
/ * *
* Which browser to launch .
* @defaultValue ` chrome `
* /
product? : Product ;
/ * *
2021-09-10 18:59:43 +00:00
* { @link https : //searchfox.org/mozilla-release/source/modules/libpref/init/all.js | Additional preferences } that can be passed when launching with Firefox.
2021-02-16 09:39:31 +00:00
* /
extraPrefsFirefox? : Record < string , unknown > ;
2021-05-06 20:30:04 +00:00
/ * *
* Whether to wait for the initial page to be ready .
* Useful when a user explicitly disables that ( e . g . ` --no-startup-window ` for Chrome ) .
2023-03-29 13:27:29 +00:00
* @defaultValue ` true `
2021-05-06 20:30:04 +00:00
* /
waitForInitialPage? : boolean ;
2020-05-12 15:30:13 +00:00
}
2021-02-16 09:39:31 +00:00
/ * *
* Utility type exposed to enable users to define options that can be passed to
* ` puppeteer.launch ` without having to list the set of all types .
* @public
* /
export type PuppeteerNodeLaunchOptions = BrowserLaunchArgumentOptions &
LaunchOptions &
BrowserConnectOptions ;