Skip to content

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

Name Type Description
options Object eg. {headless: true|false, args:[‘–window-size=1440,900’]} Default: {headless:true}.
options.headless boolean Option to open browser in headless/headful mode. Default: true.
options.args Array Chromium browser launch options. Default: [].
options.host string Remote host to connect to. Default: '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: 0.
options.useHostName number If the browser should be called using the hostname itself or with IP address Default: false.
options.secure number HTTPS/WSS frontend. Defaults to false. Default: false.
options.ignoreCertificateErrors boolean Option to ignore certificate errors. Default: true.
options.observe boolean Option to run each command after a delay. Useful to observe what is happening in the browser. Default: false.
options.observeTime number Option to modify delay time for observe mode. Accepts value in milliseconds. Default: 3000.
options.dumpio boolean Option to dump IO from browser. Default: false.

Returns

Type Description
Promise<void>