Skip to content

Chrome Setup

Andrei Rusu edited this page Apr 10, 2015 · 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] (http://chromedriver.storage.googleapis.com/index.html).

2. Configure the path - either add the path to the ChromeDriver binary to the system PATH or set the location in your nightwatch.json, under the selenium options like so:

"selenium" : {
  ...
  "cli_args" : {
    "webdriver.chrome.driver" : "/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"]
  }
}

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"]
}