Skip to content

Commit

Permalink
feat(Launcher): add devtools option (#953)
Browse files Browse the repository at this point in the history
This patch adds a `devtools` option to the launcher that adds the `--auto-open-devtools-for-tabs`
argument to the launched chrome.

Fixes #864.
  • Loading branch information
vsemozhetbyt authored and aslushnikov committed Oct 10, 2017
1 parent e6af6e1 commit f1aa18a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
3 changes: 2 additions & 1 deletion docs/api.md
Expand Up @@ -211,7 +211,7 @@ This methods attaches Puppeteer to an existing Chromium instance.
#### puppeteer.launch([options])
- `options` <[Object]> Set of configurable options to set on the browser. Can have the following fields:
- `ignoreHTTPSErrors` <[boolean]> Whether to ignore HTTPS errors during navigation. Defaults to `false`.
- `headless` <[boolean]> Whether to run Chromium in [headless mode](https://developers.google.com/web/updates/2017/04/headless-chrome). Defaults to `true`.
- `headless` <[boolean]> Whether to run Chromium in [headless mode](https://developers.google.com/web/updates/2017/04/headless-chrome). Defaults to `true` unless the `devtools` option is `true`.
- `executablePath` <[string]> Path to a Chromium executable to run instead of bundled Chromium. If `executablePath` is a relative path, then it is resolved relative to [current working directory](https://nodejs.org/api/process.html#process_process_cwd).
- `slowMo` <[number]> Slows down Puppeteer operations by the specified amount of milliseconds. Useful so that you can see what is going on.
- `args` <[Array]<[string]>> Additional arguments to pass to the Chromium instance. List of Chromium flags can be found [here](http://peter.sh/experiments/chromium-command-line-switches/).
Expand All @@ -220,6 +220,7 @@ This methods attaches Puppeteer to an existing Chromium instance.
- `dumpio` <[boolean]> Whether to pipe browser process stdout and stderr into `process.stdout` and `process.stderr`. Defaults to `false`.
- `userDataDir` <[string]> Path to a [User Data Directory](https://chromium.googlesource.com/chromium/src/+/master/docs/user_data_dir.md).
- `env` <[Object]> Specify environment variables that will be visible to Chromium. Defaults to `process.env`.
- `devtools` <[boolean]> Wether to auto-open DevTools window for each tab. If this option is `true`, the `headless` option will be set `false`.

This comment has been minimized.

Copy link
@xprudhomme

xprudhomme Nov 20, 2017

Contributor

Typo need quick fix: should be "Whether" instead of "Wether" : )

This comment has been minimized.

Copy link
@aslushnikov

aslushnikov Nov 20, 2017

Contributor

@xavatar PR would be much appreciated! 👍

- returns: <[Promise]<[Browser]>> Promise which resolves to browser instance.

The method launches a browser instance with given arguments. The browser will be closed when the parent node.js process is closed.
Expand Down
4 changes: 4 additions & 0 deletions lib/Launcher.js
Expand Up @@ -72,6 +72,10 @@ class Launcher {

chromeArguments.push(`--user-data-dir=${options.userDataDir || temporaryUserDataDir}`);
}
if (options.devtools === true) {
chromeArguments.push('--auto-open-devtools-for-tabs');
options.headless = false;
}
if (typeof options.headless !== 'boolean' || options.headless) {
chromeArguments.push(
'--headless',
Expand Down

0 comments on commit f1aa18a

Please sign in to comment.