basically the same as this: https://stackoverflow.com/questions/25163674/can-you-do-multiple-onprepares-per-browser-instance but since there were no answers or comments I'll post again.
I want to login with two user profiles on two separate browsers.
I'd be using something like this in my config file:
multiCapabilities: [{
browserName: 'chrome',
specs: ['profile_1.spec.js'],
login: {email: 'profile_1',
password: 'pw1'}
}, {
browserName: 'chrome',
specs: ['profile_2.spec.js'],
login: { email: 'profile_2',
password: 'pw2'}
}]
Since my login page isn't angular I need to use onPrepare and I can only set login params once.
Is there a way pass the login params from the multiCapabilities array to the onPrepare function or to have specific onPrepares inside the multiCapabilities objects?
You can work around this by adding logic in your code.
At protractor 1.7, you can call browser.getProcessedConfig(), which returns your config.
You can add arbitrary fields into your browserName.
multiCapabilities: [{
browserName: 'chrome',
specs: ['profile_1.spec.js'],
name: 'profile1'
}, {
browserName: 'chrome',
specs: ['profile_2.spec.js'],
name: 'profile2'
}]
and use params:
params: {
profile1: {
email: 'CA',
password: 'pw123'
},
profile2: {
email: 'Sup',
password: 'pw123'
}
},
Then in on prepare:
onPrepare: function() {
browser.getProcessedConfig().then(function(config) {
//do something with browser.params[config.capabilities.name]
});
},
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With