【问题标题】:Protractor - Setting DPI with chromeOptions量角器 - 使用 chromeOptions 设置 DPI
【发布时间】:2014-07-11 22:00:23
【问题描述】:

我正在使用量角器编写功能测试,并尝试在桌面上使用 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 移动仿真?

【问题讨论】:

    标签: angularjs functional-testing protractor


    【解决方案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
                    }
                }
            }
        },
    

    【讨论】:

    • 请解释您的答案以便更好地理解。仅代码的答案在堆栈上不受欢迎
    猜你喜欢
    • 2016-12-11
    • 2020-11-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-11-10
    • 1970-01-01
    • 2018-06-04
    • 1970-01-01
    相关资源
    最近更新 更多