Nightwatch v2.0.0-alpha.3
New features
- Added integrated test runner for Cucumber - more info on config and usage available in examples folder
- Added new 'createClient()' programatic api exported on the main library; usage:
const Nightwatch = require('nightwatch');
const client = Nightwatch.createClient({
headless: true,
output: true,
silent: true, // set to false to enable verbose logging
browserName: 'firefox', // can be either: firefox, chrome, safari, or edge
timeout: 10000, // set the global timeout to be used with waitFor commands and when retrying assertions/expects
env: null, // set the current test environment from the nightwatch config
desiredCapabilities: {
// any additional capabilities needed
},
globals: {}, // can define/overwrite test globals here; when using a third-party test runner only the global hooks onBrowserNavigate/onBrowserQuit are supported
parallel: false, // when the test runner used supports running tests in parallel; set to true if you need the webdriver port to be randomly generated
// All other settings can be overwritten here, such as:
disable_colors: false
});
const browser = await client.session();
Improvements
-
Updated the bundled Mocha test runner to use Mocha v9 and added other features supported by the default nightwatch test runner (such as using test tags, global hooks etc.); pending Mocha v9.1.3 which contains mochajs/mocha#4760
-
New API commands:
-
browser.navigateTo(url, [callback])
- navigates to a new url. Accepts also relative urls iflaunchUrl
is defined in the config and will executeonBrowserNavigate
global hook after the url is loaded. -
browser.getCurrentUrl([callback])
-
browser.quit([callback])
- ends the session and closes down the test WebDriver server, if one is running. This is similar to calling the.end()
command, but the former doesn't quit the WebDriver session. It also executes theonBrowserQuit
global hook before ending the session. -
browser.setAttribute([using], selector, property, [callback])
- set the value of a specified DOM attribute for the given element.
-
Fixes
- Fixed an issue with using
moveToElement
andmoveTo
api commands - Fixed isVisible() command to use the proper action from selenium-webdriver
- Fixed an issue where the sink process used by the Webdriver child process was causing the runner to stop working on Windows
- Renamed global object "Key" to "Keys"