nightwatchjs / nightwatch

Integrated end-to-end testing framework written in Node.js and using W3C Webdriver API. Developed at @browserstack
https://nightwatchjs.org
MIT License
11.8k stars 1.31k forks source link

Settings from various test_settings environments are overwriting eachother #2041

Closed DabblesWithApps closed 5 years ago

DabblesWithApps commented 5 years ago

I have a nightwatch.conf.js file that allows nightwatch to run fine when I target certain environments. For example the following commands run without problem: nightwatch -e ie nightwatch -e ff nightwatch -e ios nightwatch -e ie,ff

My problem is that the following command causes the ff and ie environments to fail: nightwatch -e ios,ie,ff

The logs indicate the ie and ff were passed selenium.start_process = false, even though I expect them to be true:

$ nightwatch -e ios,ie,ff
ios [Test] Test Suite
ios =================
ios √ Element <#username> was visible after 1179 milliseconds.
ios Results for:  Demo test 1
ios √ [Test] Demo test 1 (7.067s)
ios √ [Test] Demo test 2 (7.381s)
ie [Test] Test Suite
ie =================
ie    POST  /wd/hub/session - ECONNREFUSED
ie Error: connect ECONNREFUSED 127.0.0.1:4444
ie   An error occurred while retrieving a new session: "Connection refused to 127.0.0.1:4444". If the
 Webdriver/Selenium service is managed by Nightwatch, check if "start_process" is set to "true".
ie        at Socket.socketErrorListener (_http_client.js:401:9)
ff [Test] Test Suite
ff =================
ff    POST  /wd/hub/session - ECONNREFUSED
ff Error: connect ECONNREFUSED 127.0.0.1:4444
ff   An error occurred while retrieving a new session: "Connection refused to 127.0.0.1:4444". If the
 Webdriver/Selenium service is managed by Nightwatch, check if "start_process" is set to "true".
ff        at Socket.socketErrorListener (_http_client.js:401:9)

The behavior outlined in the log contradicts my test settings:

    "test_settings" : {
      "ios" : {
        "selenium": {
          "start_process" : false
        },
        "selenium_port"  : 4723,
        "selenium_host"  : MY_REMOTE_HOST_IS_HERE,
        ...
      },    
      "ff" : {
        "selenium" : {
          "start_process": true,
          "host": "localhost",
          "server_path": seleniumServerStandaloneJarPath,
          ...
      },
      "ie" : {
        "selenium" : {
          "start_process": true,
          "host": "localhost",
          "server_path": seleniumServerStandaloneJarPath,
          ...
      }
  }

Any help would be greatly appreciated. Apologies if I am misunderstanding something.

DabblesWithApps commented 5 years ago

per http://nightwatchjs.org/guide#test-environments, when using test_settings:

A "default" environment is required. All the other environments are inheriting from default and can overwrite settings as needed.

I resolved the issue by adding a "default" environment like so:

    "test_settings" : {
      "default" : {
        "selenium" : {
          "start_process" : true
        }
      },
      ...