Reputation: 11
I'm writing functional tests with protractor and am trying to emulate a mobile device using chrome on a desktop. I've successfully set the user agent with:
config.capabilities = {
browserName: 'chrome',
chromeOptions: {
args: ['--user-agent="Mozilla/5.0 (iPad; CPU OS 7_0 like Mac OS X) AppleWebKit/537.51.1 (KHTML, like Gecko) Version/7.0 Mobile/11A465 Safari/9537.53"']
}
};
Now, I'd like to change the DPI to reflect mobile devices (usually with a DPI of 2). I've explored other args and came across --ash-host-window-bounds (http://peter.sh/experiments/chromium-command-line-switches/#ash-host-window-bounds). I've tried:
chromeOptions: { args: ['--ash-host-window-bounds="1024x768*2"'] }
It seems like the argument doesn't work with protractor, as it does not affect the window dimensions when removing the DPI argument.
How could I set the DPI? Or, how could I enable Chrome Mobile Emulation via chromeOptions?
Upvotes: 1
Views: 1162
Reputation: 11
capabilities: {
"browserName": 'chrome',
chromeOptions: {
args: ['--user-agent="Mozilla/5.0 (iPhone; CPU iPhone OS 8_0 like Mac OS X) AppleWebKit/600.1.3 (KHTML, like Gecko) Version/8.0 Mobile/12A4345d Safari/600.1.4"'],
mobileEmulation: {
"device": 'Apple iPhone 6 Plus',
"deviceMetrics": {
"width": 414,
"height": 736,
"pixelRatio": 3.0
}
}
}
},
Upvotes: 1