2

There are several elements of a Protractor configuration that I need to modify at run-time, most importantly some values of the multiCapabilities object:

...
multiCapabilities: [
    {
        'build': buildNumber,
        'app': 'app' + buildNumber + '.apk',
        'browserName': '',
        'appiumVersion': '1.4.16',
        'deviceName': 'Android Emulator',
        'deviceOrientation': 'portrait',
        'platformVersion': '5.1',
        'platformName': 'Android',
        'autoWebview': true
    },
    {
       ...
    }
],
...

Specifically, I'm running these tests against a specific build of an app that has been uploaded to SauceLabs. I'd like to be able to somehow set the 'build' and 'app' values dynamically.

Unfortunately, the Grunt Protractor Runner does not support the multiCapabilities feature, otherwise it could be handled using that wrapper.

Joel Skrepnek
  • 1,651
  • 1
  • 13
  • 21

1 Answers1

1

One option would be to use browser.params and parameterize your tests from the command-line arguments. In this case, use getMultiCapabilities() method:

getMultiCapabilities: function () {
    var buildNumber = browser.params.build,
        app = browser.params.app;

    return [
        {
            'build': buildNumber,
            'app': app,
            'browserName': '',
            'appiumVersion': '1.4.16',
            'deviceName': 'Android Emulator',
            'deviceOrientation': 'portrait',
            'platformVersion': '5.1',
            'platformName': 'Android',
            'autoWebview': true
        },
        {
           ...
        }
    ],
},

Usage:

protractor protractor.conf.js --params.build="build" --params.app="app"
Community
  • 1
  • 1
alecxe
  • 462,703
  • 120
  • 1,088
  • 1,195