2020-05-12 15:30:13 +00:00
/ * *
* Copyright 2020 Google Inc . All rights reserved .
*
* Licensed under the Apache License , Version 2.0 ( the "License" ) ;
* you may not use this file except in compliance with the License .
* You may obtain a copy of the License at
*
* http : //www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing , software
* distributed under the License is distributed on an "AS IS" BASIS ,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND , either express or implied .
* See the License for the specific language governing permissions and
* limitations under the License .
* /
2021-02-16 09:39:31 +00:00
import { BrowserConnectOptions } from '../common/BrowserConnector.js' ;
import { Product } from '../common/Product.js' ;
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 .
* @defaultValue true
* /
2020-05-12 15:30:13 +00:00
headless? : boolean ;
2021-02-16 09:39:31 +00:00
/ * *
* Path to a user data directory .
* { @link https : //chromium.googlesource.com/chromium/src/+/master/docs/user_data_dir.md | see the Chromium docs}
* 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
* ` true ` , then ` headless ` will be set to ` false ` automatically .
* @defaultValue ` false `
* /
2020-05-12 15:30:13 +00:00
devtools? : boolean ;
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-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 .
* @defaultValue false
* /
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 .
* @defaultValue 30000 ( 30 seconds ) .
* /
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 ` .
* @defaultValue false
* /
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 .
* @defaultValue false
* /
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 ;
/ * *
* { @link https : //developer.mozilla.org/en-US/docs/Mozilla/Preferences/Preference_reference | Additional preferences } that can be passed when launching with Firefox.
* /
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 ) .
* @defaultValue true
* /
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 ;