Search code examples
jasmineprotractorsaucelabs

Retrieve the current platform in SauceLabs


I'm trying to write my custom Jasmine reporter for my Protractor tests running on SauceLabs.

I can easily get the current browser using browser.getCapabilities() but how can I get the platform?

var multiCapabilities = [
    {
        'browserName': 'chrome',
        'platform': 'Windows 7',
    },
    {
        'browserName': 'chrome',
        'platform': 'Linux',
    }
];

exports.config = {
    framework: 'jasmine2',
    onPrepare: function () {
        browser.getCapabilities().then(function (capabilities) {
            var browserName = capabilities.caps_.browserName
            var browserVersion = capabilities.caps_.version

            // How can I get the full platform here??? i.e OS name + version
        })
    }
};

Thanks!


Solution

  • This will return the value you are looking for:

      browser.getProcessedConfig().then(function (config) {
            var platformName = config.capabilities.platform;
          });
    

    All of the capabilities are available with this method, so you could use browser.getProcessedConfig() for the browserName and browserVersion as well.