我正在使用量角器编写功能测试,并试图在桌面上使用chrome模拟移动设备。我已成功设置用户代理:
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"']
}
};
现在,我想更改DPI以反映移动设备(通常DPI为2)。我已经探索过其他args并遇到了--ash-host-window-bounds(http://peter.sh/experiments/chromium-command-line-switches/#ash-host-window-bounds)。我试过了:
chromeOptions: { args: ['--ash-host-window-bounds="1024x768*2"'] }
看起来这个参数不适用于量角器,因为它在移除DPI参数时不会影响窗口尺寸。
我如何设置DPI?或者,我如何通过chromeOptions启用Chrome移动仿真?
答案 0 :(得分:1)
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
}
}
}
},