What's New in v2
Nightwatch 2.0 contains a wide range of new features and improvements for writing and running tests as well as full cross-browser testing support for W3C WebDriver compliant browsers.
The underlying architecture for communicating with the browsers has been completely reworked in order to build on top of the official Selenium-Webdriver Node.js library. This means that Nightwatch is now much better equipped for cross-browser integration and DOM element handling, and overall is able to deliver more stable and faster tests.
Since Nightwatch 2 builds on top of Selenium now, it is never behind any new WebDriver API.
Nightwatch 2 brings support for working with the newer Actions API from Selenium WebDriver for performing complex user gestures.
Nightwatch 2 brings integrated support for using Cucumber.js directly as an alternative test runner. No other plugins are necessary, other than the Cucumber library itself (version 7.3 or higher).
The integrated Mocha runner has been upgraded to use Mocha v9 and also the implementation has been updated to match most of the features that Nightwatch offers in its own default test runner, like the ability to use tags or global test hooks. You can now also use reporters like Mochawesome.
When using ChromeDriver or EdgeDriver it is now possible to execute commands via the Chrome DevTools protocol.
.ensureAPI is a direct mapping to the existing until module from Selenium and provides an extra level of flexibility for performing assertions in tests.
A brand new programmatic api is available in Nightwatch 2, which makes it very easy to use Nightwatch externally, either by creating your custom runner or by using external test runners like Jest, Mocha, or Ava.
The newly added element() global object adds to Nightwatch 2 the commands from the Selenium WebElement instance.
- .firefox specific commands
- .chrome specific commands
- specify page commands as an ES6 class (details);
--fail-fastcli argument to abort the test runner after a failed test suite;
- added support to use the config file as Promise;
- added support to use glob patterns in config for
browseris now available as a global; other globals:
- added support to use Selenium Capabilities objects in Nightwatch config
We have tried to keep the breaking changes to a minimum, however some changes were unavoidable. See the migrate to v2 guide for details.