Name: chrome-launcher
Owner: GoogleChrome
Description: Launch Google Chrome with ease from node.
Created: 2017-08-29 21:44:00.0
Updated: 2018-05-11 00:42:51.0
Pushed: 2018-04-16 21:13:17.0
Homepage: https://www.npmjs.com/package/chrome-launcher
Size: 162
Language: TypeScript
GitHub Committers
User | Most Recent Commit | # Commits |
---|
Other Committers
User | Most Recent Commit | # Commits |
---|
Launch Google Chrome with ease from node.
remote-debugging-port
on an available portkill()
Ctrl-C
(by default) to terminate the Chrome processOnce launched, interacting with the browser must be done over the devtools protocol, typically via chrome-remote-interface. For many cases Puppeteer is recommended, though it has its own chrome launching mechanism.
add chrome-launcher
with npm:
install chrome-launcher
.launch([opts])
(optional) remote debugging port number to use. If provided port is already busy, launch() will reject
Default: an available port is autoselected
rt: number;
(optional) Additional flags to pass to Chrome, for example: ['--headless', '--disable-gpu']
See: https://github.com/GoogleChrome/chrome-launcher/blob/master/docs/chrome-flags-for-tools.md
Do note, many flags are set by default: https://github.com/GoogleChrome/chrome-launcher/blob/master/src/flags.ts
romeFlags: Array<string>;
(optional) Close the Chrome process on `Ctrl-C`
Default: true
ndleSIGINT: boolean;
(optional) Explicit path of intended Chrome binary
* If this `chromePath` option is defined, it will be used.
* Otherwise, the `CHROME_PATH` env variable will be used if set. (`LIGHTHOUSE_CHROMIUM_PATH` is deprecated)
* Otherwise, a detected Chrome Canary will be used if found
* Otherwise, a detected Chrome (stable) will be used
romePath: string;
(optional) Chrome profile path to use, if set to `false` then the default profile will be used.
By default, a fresh Chrome profile will be created
erDataDir: string | boolean;
(optional) Starting URL to open the browser with
Default: `about:blank`
artingUrl: string;
(optional) Logging level: verbose, info, error, silent
Default: 'silent'
gLevel: string;
(optional) Flags specific in [flags.ts](src/flags.ts) will not be included.
Typically used with the defaultFlags() method and chromeFlags option.
Default: false
noreDefaultFlags: boolean;
(optional) Interval in ms, which defines how often launcher checks browser port to be ready.
Default: 500
nnectionPollInterval: number;
(optional) A number of retries, before browser launch considered unsuccessful.
Default: 50
xConnectionRetries: number;
(optional) A dict of environmental key value pairs to pass to the spawned chrome process.
vVars: {[key: string]: string};
.launch().then(chrome => ...
he remote debugging port exposed by the launched chrome
me.port: number;
ethod to kill Chrome (and cleanup the profile folder)
me.kill: () => Promise<{}>;
he process id
me.pid: number;
he childProcess object for the launched Chrome
me.process: childProcess
.defaultFlags()
Returns an Array<string>
of the default flags Chrome is launched with. Typically used along with the ignoreDefaultFlags
and chromeFlags
options.
Note: This array will exclude the following flags: --remote-debugging-port
--disable-setuid-sandbox
--user-data-dir
.
t chromeLauncher = require('chrome-launcher');
meLauncher.launch({
artingUrl: 'https://google.com'
hen(chrome => {
nsole.log(`Chrome debugging port running on ${chrome.port}`);
t chromeLauncher = require('chrome-launcher');
meLauncher.launch({
artingUrl: 'https://google.com',
romeFlags: ['--headless', '--disable-gpu']
hen(chrome => {
nsole.log(`Chrome debugging port running on ${chrome.port}`);
In a CI environment like Travis, Chrome may not be installed. If you want to use chrome-launcher
, Travis can install Chrome at run time with an addon. Alternatively, you can also install Chrome using the download-chrome.sh
script.
Then in .travis.yml
, use it like so:
uage: node_js
all:
yarn install
re_script:
export DISPLAY=:99.0
export CHROME_PATH="$(pwd)/chrome-linux/chrome"
sh -e /etc/init.d/xvfb start
sleep 3 # wait for xvfb to boot
ns:
rome: stable