Skip to content

Chrome Setup

Andrei Rusu edited this page Jun 14, 2019 · 8 revisions

Running tests in Chrome is possible with the aid of ChromeDriver.

Getting started

1. Download ChromeDriver - download the latest version of the ChromeDriver for your platform from the Downloads page.

2. Configure the path - Set the location of the ChromeDriver binary in your nightwatch.json, under the webdriver options like so:

"webdriver" : {
  "server_path" : "/path/to/chromedriver"
}

Chrome Capabilities

This is a list of all the Chrome-specific desired capabilities, which are all under the ChromeOptions dictionary.

Name Type Default Description
args array of strings List of command-line arguments to use when starting Chrome. Arguments with an associated value should be separated by a '=' sign (e.g., ["start-maximized", "user-data-dir=/tmp/temp_profile"]). See below for usage.
binary string Path to the Chrome executable to use (on Mac OS X, this should be the actual binary, not just the app. e.g., '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome')
extensions array of strings A list of Chrome extensions to install on startup. Each item in the list should be a base-64 encoded packed Chrome extension (.crx)

For a complete list of supported Chrome capabilities please refer to ChromeDriver Capabilities

Command Line Switches

A full list of command line switches for Chrome is available here. To use set the switch in your desiredCapabilities in your nightwatch.json, e.g.:

"desiredCapabilities" : {
  "browserName" : "chrome",
  "javascriptEnabled" : true,
  "acceptSslCerts" : true,
  "chromeOptions" : {
    "args" : ["start-fullscreen"]
  }
}

User Preferences

Similar to the command line switches above, it's possible to configure Chrome user preferences. For example, the following chunk of nightwatch.json disables the browser's password manager feature:

"desiredCapabilities" : {
  "browserName" : "chrome",
  "javascriptEnabled" : true,
  "acceptSslCerts" : true,
  "chromeOptions" : {
    "prefs" : {
      "credentials_enable_service" : false,
      "profile.password_manager_enabled" : false
    }
  }
}

Chrome running in a Docker container

If you happen to be running Chrome inside a Docker container, remember to also include this in your desiredCapabilities otherwise the Chromedriver will have problems accessing the Chrome binary.

"chromeOptions" : {
  "args" : ["--no-sandbox"]
}