browserstack / nightwatch-browserstack

Selenium examples for Nightwatch and BrowserStack Automate
https://www.browserstack.com
77 stars 62 forks source link

capabilities config mobile #41

Open webdesignberlin opened 3 years ago

webdesignberlin commented 3 years ago

hello, i'm trying to get the mobile project up and running. I looked for the capabilities out of here https://www.browserstack.com/automate/capabilities.

but as soon as I start the test, I get an error: Unknown browser: "iphone"

Ideas or suggestions? best regards, micha

var capabilities = {
    "os_version" : "14",
    "device" : "iPhone 12",
    "real_mobile" : "false",
    "build" : "nightwatch-browserstack",
    "browserstack.local" : "false",
    "deviceOrientation" : "landscape",
    "browserstack.user" : "xxx",
    "browserstack.key" : "xxx",
    "browserName" : "iPhone"
    };

nightwatch_config = {
    src_folders : [ "tests/single" ],  // Specifies which tests would run

    selenium : {
      "start_process" : false,
      "host" : "hub-cloud.browserstack.com",  // Specifies the BrowserStack Hub URL
      "port" : 443
    },

    test_settings: {
      default: {
        // The following are the BrowserStack specific capabilities for all your tests that will run using this conf file.
        desiredCapabilities: capabilities,
      }
    }
  };

  // Code to copy seleniumhost/port into test settings
  for(var i in nightwatch_config.test_settings){
    var config = nightwatch_config.test_settings[i];
    config['selenium_host'] = nightwatch_config.selenium.host;
    config['selenium_port'] = nightwatch_config.selenium.port;
  }

  module.exports = nightwatch_config;
harsh-browserstack commented 3 years ago

Hey Micha,

I can see that you have passed the browserName capability as "iPhone" which is incorrect and hence getting the error, instead, can you put the browser name of your choice to test on eg:- Chrome, Safari, Firefox, and Edge.

Regards, Harsh Pathar Browserstack Support

webdesignberlin commented 3 years ago

Hi Harsh, i get them via the Capabilities Generator: https://www.browserstack.com/automate/capabilities

webdesignberlin commented 3 years ago

Some Ideas?. If i use the example of https://automate.browserstack.com/dashboard/v2/quick-start/get-started#view-test-results-on-dashboard

nightwatch_config = {
  src_folders : [ "tests/single" ],
  selenium : {
    "start_process" : false,
    "host" : "hub-cloud.browserstack.com",
    "port" : 80
  },
  common_capabilities: {
    'build': 'browserstack-build-1',
    'browserstack.user': '***',
    'browserstack.key': '***',
    'browserstack.debug': true
  },
  test_settings: {
    default: {},
    env1: {
      desiredCapabilities: {
        "device": "iPad 6th",
        "os_version": "11",
        "browserName": "ios",
        "realMobile": "true"
      }
    },
    /* env2: {
      desiredCapabilities: {
        "browser": "firefox",
        "browser_version": "latest",
        "os": "Windows",
        "os_version": "10"
      }
    },
    env3: {
      desiredCapabilities: {
        "browser": "safari",
        "browser_version": "latest",
        "os": "OS X",
        "os_version": "Big Sur"
      }
    } */
  }
};
// Code to support common capabilities
for(var i in nightwatch_config.test_settings){
  var config = nightwatch_config.test_settings[i];
  config['selenium_host'] = nightwatch_config.selenium.host;
  config['selenium_port'] = nightwatch_config.selenium.port;
  config['desiredCapabilities'] = config['desiredCapabilities'] || {};
  for(var j in nightwatch_config.common_capabilities){
    config['desiredCapabilities'][j] = config['desiredCapabilities'][j] || nightwatch_config.common_capabilities[j];
  }
}
module.exports = nightwatch_config;

i became:

`./node_modules/.bin/nightwatch -c conf/parallel.conf.js -e env1

TEST FAILURE: 1 error during execution; 0 tests failed, 0 passed (17ms) Error: Unknown browser: "ios"
`