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.79k stars 1.31k forks source link

Parallel envs require selenium binary even when single envs don't #681

Closed hukka closed 8 years ago

hukka commented 8 years ago

Trying to run multiple envs on browserstack (for example nightwatch -e bs-fx,bs-chrome) at the same time fails if the selenium standalone binary hasn't been downloaded with the following config, even when none of the configs need the server on their own:

{
  "src_folders" : ["nightwatch/"],

  "selenium" : {
    "start_process" : true,
    "server_path" : "selenium-server-standalone-2.48.2.jar",
    "log_path" : "",
    "host" : "127.0.0.1",
    "port" : 4444,
    "cli_args" : {
      "webdriver.chrome.driver" : "",
      "webdriver.ie.driver" : ""
    }
  },

  "test_settings" : {
    "default" : {
      "launch_url" : "http://localhost:8080",
      "selenium_port"  : 4444,
      "selenium_host"  : "localhost",
      "silent": true,
      "screenshots" : {
        "enabled" : true,
        "on_failure" : true,
        "on_error" : true,
        "path" : "test_screenshots/"
      },
      "desiredCapabilities": {
        "browserName": "firefox",
        "javascriptEnabled": true,
        "acceptSslCerts": true
      }
    },

    "phantom": {
      "selenium_port"  : 4444,
      "selenium_host"  : "localhost",
        "desiredCapabilities" : {
          "browserName" : "phantomjs",
          "javascriptEnabled" : true,
          "acceptSslCerts" : true,
          "phantomjs.binary.path" : "node_modules/phantomjs/bin/phantomjs"
        }
    },

    "bs-fx" : {
      "selenium_port"  : 80,
      "selenium_host"  : "hub.browserstack.com",
      "selenium": {
        "start_process" : false
      },
      "desiredCapabilities": {
        "browserName": "firefox",
        "javascriptEnabled": true,
        "acceptSslCerts": true,
        "browserstack.user": "${BROWSERSTACK_USER}",
        "browserstack.key": "${BROWSERSTACK_KEY}",
        "browserstack.local": true
      }
    },
    "bs-chrome" : {
      "selenium_port"  : 80,
      "selenium_host"  : "hub.browserstack.com",
      "selenium": {
        "start_process" : false
      },
      "desiredCapabilities": {
        "browserName": "chrome",
        "javascriptEnabled": true,
        "acceptSslCerts": true,
        "browserstack.user": "${BROWSERSTACK_USER}",
        "browserstack.key": "${BROWSERSTACK_KEY}",
        "browserstack.local": true
      }
    },
    "bs-ie" : {
      "selenium_port"  : 80,
      "selenium_host"  : "hub.browserstack.com",
      "selenium": {
        "start_process" : false
      },
      "desiredCapabilities": {
        "browserName": "internet explorer",
        "version": "11",
        "platform": "WIN8",
        "javascriptEnabled": true,
        "acceptSslCerts": true,
        "browserstack.user": "${BROWSERSTACK_USER}",
        "browserstack.key": "${BROWSERSTACK_KEY}",
        "browserstack.local": true
      }
    },
    "bs-android" : {
      "selenium_port"  : 80,
      "selenium_host"  : "hub.browserstack.com",
      "selenium": {
        "start_process" : false
      },
      "desiredCapabilities": {
        "browserName": "android",
        "javascriptEnabled": true,
        "acceptSslCerts": true,
        "browserstack.user": "${BROWSERSTACK_USER}",
        "browserstack.key": "${BROWSERSTACK_KEY}",
        "browserstack.local": true
      }
    },
    "bs-iphone" : {
      "selenium_port"  : 80,
      "selenium_host"  : "hub.browserstack.com",
      "selenium": {
        "start_process" : false
      },
      "desiredCapabilities": {
        "browserName": "iPhone",
        "javascriptEnabled": true,
        "acceptSslCerts": true,
        "browserstack.user": "${BROWSERSTACK_USER}",
        "browserstack.key": "${BROWSERSTACK_KEY}",
        "browserstack.local": true
      }
    }
  }
}
StephenDavidson commented 8 years ago

My guess is that the selenium {start process: false} block does not override the parent main selenium block. There is no mention of start_process being at the environment level in the docs here. Have you tried it with selenium start_process set to false in the main selenium block? If it works there, you may need to make two separate conf files for remote vs nonremote selenium.

beatfactor commented 8 years ago

What is the output? Yes it does override the parent selenium block, or at least it should be.

On Tue, Oct 13, 2015 at 7:26 PM, Stephen Davidson notifications@github.com wrote:

My guess is that the selenium {start process: false} block does not override the parent selenium block. There is no mention of start_process being at the environment level in the docs here http://nightwatchjs.org/guide#test-settings. Have you tried it with selenium start_process set to false in the main selenium block? If it works there, you may need to make two separate conf files for remote vs nonremote selenium.

— Reply to this email directly or view it on GitHub https://github.com/nightwatchjs/nightwatch/issues/681#issuecomment-147784480 .

hukka commented 8 years ago

When the selenium jar is available and multiple envs are given:

Starting selenium server in parallel mode... started - PID:  3437

Started child process for: bs-fx environment 
Started child process for: bs-chrome environment

and so on, outputting the test results after both have finished.

Multiple envs after deleting the selenium jar:

Starting selenium server in parallel mode... There was an error while starting the Selenium server:

There was an error while running the test.

And finally after trying just one env, still without the jar:

[Frontpage] Test Suite
======================

Running:  Frontpage map loads

and so on, continuing with the tests.

beatfactor commented 8 years ago

Which OS and nightwatch version?

beatfactor commented 8 years ago

Is it possible to provide a complete reproducible scenario? I.e. a sample test file against a public url (you can use one of the examples) with separate config files.

beatfactor commented 8 years ago

The problem here seems to be that the parent selenium block is not overwritten when running in parallel mode, which is actually as intended. Overwriting the main selenium settings is only possible when running in regular mode.