How to pass Environment based parameters in jasmine framework to protractor test
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.
There's no support for doing this at the moment.
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.
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
can any one give any suggestion?
Please read the contributing guidelines; these types of questions are ill-suited for GitHub. Thanks!
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 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+ "_";});
