Dear1ofGdBear
Dear1ofGdBear

Reputation: 985

How to run paralllel tests with Nightwatch.js in Browserstack

The documentation for Nightwatch.js with Browserstack is pretty sparse. I currently have an automated test set up with Javascript and the tests are set up to run on Browserstack. It loops through the browsers and runs the test repeatedly on different browsers, one at a time. How do I run parallel tests in Browserstack using Nightwatch.js?

I think I have the settings.json below set up properly, but please let me know of changes that need to be made.

Also, since the way to run the test on multiple instances of the webdriver or Browserstack is to run from the command line:

nightwatch –e default,chrome

does that mean that the choice of browser is limited to browser name? What if my settings.json contains multiple Firefox browsers each being a different version and sunning on a different OS?

Help is appreciated. Thanks!

Here is my settings.json file:

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

  "selenium" : {
    "start_process" : false,
    "host" : "hub.browserstack.com",
    "port" : 80
  },

  "test_settings" : {
    "default" : {
      "launch_url" : "http://hub.browserstack.com",
      "selenium_port"  : 80,
      "selenium_host"  : "hub.browserstack.com",
      "silent": true,
      "screenshots" : {
        "enabled" : true,
        "path" : ""
    },

"desiredCapabilities": {
  "browserName": "Firefox",
  "browser_version": "42.0",
  "os": "Windows",
  "os_version": "8.1",
  "javascriptEnabled": true,
  "acceptSslCerts": true,
  "browserstack.user": "<username>",
  "browserstack.key": "<access key>"
 }
},

  "chrome" : {
    "desiredCapabilities": {
      "browserName": "Chrome",
      "browser_version": "46",
      "os": "Windows",
      "os_version": "10",
      "javascriptEnabled": true,
      "acceptSslCerts": true,
      "browserstack.user": "<username>",
      "browserstack.key": "<access key>"
    }
},

  "ie" : {
    "desiredCapabilities" : { 
      "browserName": "internet explorer",
      "browser_version": "10",
      "os": "Windows",
      "os_version": "8",
      "javascriptEnabled": true,
      "acceptSslCerts": true,
      "browserstack.user": "<username>",
      "browserstack.key": "<access key>"
    }
  }
}

Upvotes: 2

Views: 2093

Answers (1)

Dear1ofGdBear
Dear1ofGdBear

Reputation: 985

It just needs to be chained on with the "test_settings". The settings for Browserstack need to be passed as each time a new browser is instantiated.

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

  "selenium" : {
    "start_process" : false,
    "host" : "hub.browserstack.com",
    "port" : 80
  },

  "test_settings" : {
    "firefox" : {
      "launch_url" : "http://hub.browserstack.com",
      "selenium_port"  : 80,
      "selenium_host"  : "hub.browserstack.com",
      "silent": true,
      "screenshots" : {
        "enabled" : false,
        "path" : ""
      },
      "desiredCapabilities": {
        "browserName": "firefox",
        "javascriptEnabled": true,
        "acceptSslCerts": true,
        "browserstack.user": "<username>",
        "browserstack.key": "<access key>"
      }
    },
    "chrome" : {
      "launch_url" : "http://hub.browserstack.com",
      "selenium_port"  : 80,
      "selenium_host"  : "hub.browserstack.com",
      "silent": true,
      "screenshots" : {
        "enabled" : false,
        "path" : ""
      },
      "desiredCapabilities": {
        "browserName": "Chrome",
        "os": "Windows",
        "browser_version": "46.0",
        "os_version": "0",
        "javascriptEnabled": true,
        "acceptSslCerts": true,
        "browserstack.user": "<username>",
        "browserstack.key": "<access key>"
      }
    },
    "safari" : {
      "launch_url" : "http://hub.browserstack.com",
      "selenium_port"  : 80,
      "selenium_host"  : "hub.browserstack.com",
      "silent": true,
      "screenshots" : {
        "enabled" : false,
        "path" : ""
      },
      "desiredCapabilities": {
        "browserstack.ie.enablePopups": true,
        "browserName": "safari",
        "javascriptEnabled": true,
        "acceptSslCerts": true,
        "browserstack.user": "<username>",
        "browserstack.key": "<access key>"
      }
    },
    "ie" : {
      "launch_url" : "http://hub.browserstack.com",
      "selenium_port"  : 80,
      "selenium_host"  : "hub.browserstack.com",
      "silent": true,
      "screenshots" : {
        "enabled" : false,
        "path" : ""
      },
      "desiredCapabilities": {
        "browserstack.ie.enablePopups": true,
        "browserName": "internet explorer",
        "javascriptEnabled": true,
        "acceptSslCerts": true,
        "browserstack.user": "<username>",
        "browserstack.key": "<access key>"
      }
    }
  }
}

Upvotes: 2

Related Questions