What's new in Nightwatch v2

The Nightwatch team has completely redesigned the underlying architecture of Nightwatch for better cross-browser integration, more reliable DOM element handling and faster tests. It now uses the official Selenium Webdriver bindings for Node.js.

Here are the key features and improvements that make Nightwatch more powerful than ever before:

Support for Actions API

Automate complex gestures reliably with the new user actions API (via the existing .perform() command).

Expanded automatic command retries

Nightwatch will retry failed element commands (such as when click encounters errors like element click intercepted).

New relative element locators

The new Selenium 4 relative locators are available by default in Nightwatch. It also improves upon the existing locators via the Selenium By() API.

Built-in support for working with file uploads

Uploading files with Nightwatch could be cumbersome previously, but v2 has a built-in command which works with the FileDetector API.

Support for extended Capabilities objects

The primary way of defining capabilities will still be as part of the nightwatch.conf.js config file, but in v2, all capabilities objects created with the Selenium Capabilities API are also supported by default.

Setting network conditions in Chrome

Manipulating network conditions is a regularly needed feature when working with browser automation and v2 supports it for Chrome and Edge initially.

Support for working with Devtools Protocol

You can now execute Chrome DevTools commands with Nightwatch. The Chrome DevTools Protocol allows for tools to instrument, inspect, debug and profile Chromium-based browsers, such as Chrome and Edge.

Ready for Webdriver BiDi

The new BiDirectional WebDriver Protocol is by far one of the most exciting recent developments in the Selenium project. These APIs will allow you to get console or Javascript error messages from the browser. As soon as it is available, it will become part of Nightwatch as well. You can follow the development on the Selenium website.

Various new command APIs

Nightwatch v2 will also bring a new .ensure assert API which will mirror the Selenium until APIs, global element(), expect(), by(), and browser objects which will enhance the experience of writing tests and provide more flexibility.

Test runner improvements

Nightwatch v2 will also bring some improvements to the test runner, like the ability to rerun only failed tests and improved support for parallel test execution.


This list is not exhaustive and Nightwatch v2 has a host of new updates. Visit nightwatch.org to learn more and upgrade to the latest version.

About Nightwatch

Nightwatch was published at the beginning of 2014 and was created as a complete and integrated framework that would enable engineers to write end-to-end tests quickly and require as little configuration and maintenance as possible.

Nightwatch recently joined the BrowserStack family, while continuing to develop Nightwatch as an autonomous open-source project. For developers who use Nightwatch.js for their testing needs, Nightwatch will always remain free and open-source. Together, BrowserStack and Nightwatch.js teams will make the framework better by improving the overall experience for developers and maintainers.

This piece is written by Andrei Rusu and was originally published here.