openBrowser
Launches a browser with a tab. The browser will be closed when the parent node.js process is closed.
Note :
openBrowser
launches the browser in headless mode by default, but when
openBrowser
is called from
repl
it launches the browser in headful mode.
Examples
await openBrowser({headless: false})
await openBrowser()
await openBrowser({args:['--window-size=1440,900']})
await openBrowser({args: [
'--disable-gpu',
'--disable-dev-shm-usage',
'--disable-setuid-sandbox',
'--no-first-run',
'--no-sandbox',
'--no-zygote']}) # These are recommended args that has to be passed when running in docker
Parameters
-
options
Object -
eg. {headless: true|false, args:['--window-size=1440,900']}
- Default value
-
{headless:true}
-
options.headless
boolean -
Option to open browser in headless/headful mode.
- Default value
-
true
-
options.args
Array<string> -
Chromium browser launch options.
- Default value
-
[]
-
options.host
string -
Remote host to connect to.
- Default value
-
'127.0.0.1'
-
options.target
string -
Determines which target the client should interact.(https://github.com/cyrus-and/chrome-remote-interface#cdpoptions-callback)
-
options.port
number -
Remote debugging port, if not given connects to any open port.
- Default value
-
0
-
options.useHostName
number -
If the browser should be called using the hostname itself or with IP address
- Default value
-
false
-
options.secure
number -
HTTPS/WSS frontend. Defaults to false.
- Default value
-
false
-
options.ignoreCertificateErrors
boolean -
Option to ignore certificate errors.
- Default value
-
true
-
options.observe
boolean -
Option to run each command after a delay. Useful to observe what is happening in the browser.
- Default value
-
false
-
options.observeTime
number -
Option to modify delay time for observe mode. Accepts value in milliseconds.
- Default value
-
3000
-
options.dumpio
boolean -
Option to dump IO from browser.
- Default value
-
false
Returns
Promise<void>