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.
We have reworked the underlying architecture, which communicates with the browsers, to build on top of the official Selenium-Webdriver Node.js library. It means that Nightwatch is now much better equipped for cross-browser integration and DOM element handling, and can deliver more stable and faster tests overall.
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).
We have upgraded the integrated Mocha runner to Mocha v9. We have also updated the implementation to match most of the features that Nightwatch offers in its own default test runner, such as the ability to use tags or global test hooks. You can now also use reporters such as 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.
Please refer to the release notes section for information about the latest changes. Releases Notes.