-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
66 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
# Chrome Launcher | ||
|
||
Launch chrome with ease from node. | ||
|
||
## API | ||
|
||
#### Launch options | ||
|
||
```js | ||
chromeLauncher.launch({ | ||
// optional staring url string | ||
startingUrl: string; | ||
// optional array of (string) flags to pass to chrome | ||
chromeFlags: Array<string>; | ||
// optional explicit remote debugging port number to use. | ||
port: number; | ||
// optional, handle cleaning up chrome when node process gets killed via SIGINT | ||
handleSIGINT: boolean; | ||
// optional, explicit path to chrome to launch | ||
chromePath: string; | ||
// optional, user dir path to reuse | ||
userDataDir: string; | ||
}); | ||
``` | ||
|
||
#### Launched chrome interface | ||
|
||
```js | ||
{ | ||
// process id of chrome. | ||
pid: number; | ||
// the remote debuging port exposed by the launched chrome. | ||
port: number; | ||
// a function to kill and cleanup chrome. | ||
kill: () => Promise<{}>; | ||
} | ||
``` | ||
|
||
|
||
## Examples | ||
|
||
#### Launching chrome: | ||
|
||
```js | ||
const chromeLauncher = require('chrome-launcher') | ||
|
||
chromeLauncher.launch({ | ||
startingUrl: 'https://google.com' | ||
}).then(info => { | ||
console.log(`Chrome debugging port running on ${info.port}`); | ||
}); | ||
``` | ||
|
||
|
||
#### Launching headless chrome: | ||
|
||
```js | ||
const chromeLauncher = require('chrome-launcher') | ||
|
||
chromeLauncher.launch({ | ||
startingUrl: 'https://google.com', | ||
chromeFlags: ['--headless'] | ||
}).then(info => { | ||
console.log(`Chrome debugging port running on ${info.port}`); | ||
}); | ||
``` |