Install Node.js

From nodejs.org:

"Node.js is a platform built on Chrome's JavaScript runtime for easily building fast, scalable network applications. Node.js uses an event-driven, non-blocking I/O model that makes it lightweight and efficient, perfect for data-intensive real-time applications that run across distributed devices."

There are installation packages and instructions for most major Operating systems on its website nodejs.org. Remember to install also the npm tool, which is the node package manager and is distributed with the Node.js installer.

Install Nightwatch

To install the latest version using the npm command line tool, run the following:

npm install nightwatch
  • add -g option to make nightwatch runner available globally in your system.
  • add --save-dev option to save nightwatch as a devDependency in your package.json.

Install Browser Drivers

Depending on your target browsers, you will need one or more specific WebDriver packages. Tou can install them from NPM or download separately.

GeckoDriver

GeckoDriver can be simply installed from NPM and no further configuration is necessary.

npm install geckodriver --save-dev

Alternatively, it can be downloaded from the GeckoDriver Releases page on GitHub. Release notes are also available there.

ChromeDriver

Same as GeckoDriver, ChromeDriver can be simply installed from NPM and no further configuration is necessary.

Alternatively, it can be downloaded from the ChromeDriver Downloads page.

npm install chromedriver --save-dev

Microsoft Edge Driver

The Edge Driver can be downloaded from the official Microsoft Edge Driver homepage.

SafariDriver

The safaridriver binary is already installed on recent versions of Mac OS, however some manual configuration is needed before tests can be run against Safari.

You will need to run the following once, before using the safaridriver:

safaridriver --enable

More details are available on the Apple Developer website. See also this tutorial: Testing with WebDriver in Safari.

Install Selenium Server

Using Selenium Standalone Server used to be the de-facto standard for managing the various browser drivers and services, but starting with Nightwatch 1.0 is no longer required, nor is it recommended for testing against a single browser.

You will only need Selenium Server when testing against Internet Explorer, if you wish to run tests in parallel in multiple browsers, or in a Selenium Grid environment.

Download Java

Selenium Server is a Java application, which means you will also need to have the Java Development Kit (JDK) installed, minimum required version is 7. You can check this by running java -version from the command line.

Install From NPM

The easiest way to install the Selenium Server is from NPM. Nightwatch automatic configuration is already prepared for usage with this package against Chrome, Firefox, and Internet Explorer.

npm install selenium-server --save-dev

Download Selenium

You can find the latest Selenium Server stable and alpha version on the Selenium downloads page.

Download the selenium-server-standalone-{VERSION}.jar file and place it on the computer with the browser you want to test. In most cases this will be on your local machine and typically inside your project's source folder. A good practice is to create a separate subfolder (e.g. bin) and place it there as you might have to download other driver binaries if you want to test multiple browsers.

Running Selenium Automatically

If the server is on the same machine where Nightwatch is running, it can be started/stopped directly by the Nightwatch Test Runner.

Running Selenium Manually

To run the Selenium Server manually, from the directory with the jar run the following:

java -jar selenium-server-standalone-{VERSION}.jar

Using Selenium Standalone Server

For viewing all the run-time options, run the previous command adding the -help:

java -jar selenium-server-standalone-{VERSION}.jar -help

More info about running the Selenium Server can be found here on the official Selenium Docs

Improve this article