protractor icon indicating copy to clipboard operation
protractor copied to clipboard

How to pass Environment based parameters in jasmine framework to protractor test

Open prakashomp opened this issue 12 years ago • 7 comments

Hi,

I want to pass the arguments to the browser in jasmine frame work configuration file. like " multiCapabilities: [{ 'browserName': 'chrome', maxInstances: 1, name:'chrome', 'args': ['user=user1'] }, { 'browserName': 'firefox', shardTestFiles: true, maxInstances: 1, name:'firefox', 'args': ['user=user2']

} ], and also read in the test file how to read and use according to the browser.

prakashomp avatar Jul 02 '14 12:07 prakashomp

There's no support for doing this at the moment.

juliemr avatar Jul 02 '14 20:07 juliemr

My work around for this is was to have a setup module which included a function that determined what browser was being launched and set different variable values depending on the browser. Similar to this - http://stackoverflow.com/questions/22917219/protractor-accessing-capabilities

On 2 July 2014 21:13, Julie Ralph [email protected] wrote:

There's no support for doing this at the moment.

— Reply to this email directly or view it on GitHub https://github.com/angular/protractor/issues/1016#issuecomment-47829553.

FuturaITLtd avatar Jul 02 '14 20:07 FuturaITLtd

Thank you for your reply. now i can able to get the browser name. but i can't get the name which is assigned by user as bellow multiCapabilities: [{ 'browserName': 'chrome', 'name': 'Protractor suite tests', shardTestFiles: false, maxInstances: 1
}, { 'browserName': 'firefox', shardTestFiles: false, maxInstances: 1, 'name': 'UI Tests2' } ],

I want to retrieve the name of the instance . How to get the name of the instance

prakashomp avatar Jul 03 '14 06:07 prakashomp

can any one give any suggestion?

prakashomp avatar Jul 13 '14 08:07 prakashomp

Please read the contributing guidelines; these types of questions are ill-suited for GitHub. Thanks!

juliemr avatar Oct 03 '14 21:10 juliemr

Hi prakashomp - you can set a method in the protractor config.onPrepare section to get the browser name:

 onPrepare: function() {
     browser.getCapabilities().then(function (cap) {
         browser.params.browser = cap.caps_.browserName;
     });
}

Then use it in your spec like:

if (browser.params.browser == "safari" || browser.params.browser == "firefox") {
    //Do it special
}
else {
    //Do it normal
}

aidaeology avatar Oct 03 '14 21:10 aidaeology

@aidaeology for me its not working i have tried

capsPromise.then(function(caps){ var browserName = caps.caps_.browserName.toUpperCase(); var browserVersion = caps.caps_.version; var platform = caps.caps_.platform; var prePendStr = browserName + "" + browserVersion + ""+ platform+ "_";});

image

Saurabh06 avatar May 04 '16 13:05 Saurabh06