Migrating to Nightwatch 1.0

Adrián Garrido edited this page Jan 16, 2019 · 8 revisions

Below is a list of potentially breaking changes in version 1.0 and deprecated functionality which was removed. All attempts have been made to ensure a complete and accurate list, but there might be things which we overlooked.

Using a remote Selenium Server

When using a remote Selenium server (or when selenium server is not managed by nightwatch) or a cloud testing service (such as BrowserStack), the selenium_host / selenium_port properties need to be set accordingly, like below:

"test_settings" : {
    "default" : {
      "selenium_host": "hub-cloud.browserstack.com",
      "selenium_port": 80
    }
  }

Another option is to set the default_path_prefix to /wd/hub.

{
    webdriver: {
        default_path_prefix: '/wd/hub'
    }
}

See also http://nightwatchjs.org/gettingstarted#test-settings.

Test Hooks

  • removed this.client from after/afterEach hooks - use the client argument
  • after/afterEach currentTest.name is the name of the last test (it used to be null in after()).
  • in order not to break compatibility with early versions, afterEach hook used to accept the done callback parameter, if passed just one argument (i.e. afterEach(done) {}; that is no longer the case from 1.0, current behaviour is either: afterEach(client, done) {} or afterEach(client) {};
  • this.results and this.errors no longer passed to afterEach - use client.currentTest.results;

Global Hooks

  • global beforeEach hooks used to contain a client.currentTest.results object with initial values; now the .results object is not present anymore inside the beforeEach hooks

Global Reporter

  • consolidated the testSuite key on the results object passed to a global reporter - it is now containing the subfolders relative to the path(s) specified as the src_folders property.

Folder/File Name Filtering

  • behaviour of filter and exclude properties has changed; if both are specified, exclude is now applied on the matches from filter.

Custom Commands

  • behaviour of custom commands called with page object selectors (ie. @mySelector) has changed; before you would receive a string with the selector, now you will receive an object. For more info check issue #1237

Deprecated

nightwatch.json

  • use_ssl -> use webdriver.ssl
  • proxy -> use webdriver.proxy
  • request_timeout_options -> use webdriver.timeout_options
  • default_path_prefix -> use webdriver.default_path_prefix
  • username -> use webdriver.username
  • access_key -> use webdriver.access_key
  • password -> use webdriver.access_key

Removed deprecated:

APIs:

  • dismiss_alert
  • accept_alert
  • window_handle
  • window_handles: replaced by windowHandles
  • execute_async

Test Hooks:

  • setUp/tearDown hooks no longer work - use beforeEach/afterEach

Grunt

  • support for grunt, i.e. Nightwatch.initGrunt, has been removed
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.