Currently I'm trying emulate chrome browser on mobile devices (eg Apple iPad\\Samsung Galaxy). It works fine when hardcoded deviceName are passed in conf.js.
But I want to change devices on fly. I've tried passing deivceName parameter in command line but with no luck. It didn't update value in conf.js but after webdriver instance is started I see updated param values:
protractor mobiledevice.js --params.device="Apple iPhone 5"
-
"use strict";
var config = require('./conf.js').config;
config.params = {
device: 'Google Nexus 6'
}
config.capabilities = {
'chromeOptions': {
'mobileEmulation': {
'deviceName': config.params.device
}
}
};
exports.config = config;
Question: how do I emulate device which is passed as parameter through command line?
You can define the getMultiCapabilities
function :
exports.config = {
getMultiCapabilities: function () {
return [{
chromeOptions: {
mobileEmulation: {
deviceName: this.params.device
}
}
}];
},
// ...
};
Then pass the device
parameter:
protractor mobiledevice.js --params.device="Apple iPhone 5"
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.