Web驱动程序-如何为Microsoft Edge覆盖用户代理

时间:2018-08-20 10:26:15

标签: node.js selenium-webdriver browserstack

根据Web driver IO specification,我可以如下设置浏览器的chrome用户代理:

desiredCapabilities: {
    browserName: 'chrome',
    chromeOptions: {
         args: ['user-agent=Mozilla/5.0 (iPhone; CPU iPhone OS 7_0 like Mac OS X; en-us) AppleWebKit/537.51.1 (KHTML, like Gecko) Version/7.0 Mobile/11A465 Safari/9537.53']
    }
}

但是,我找不到使用Webdriver中的desiredCapabilities配置覆盖Microsoft Edge的方法。

2 个答案:

答案 0 :(得分:0)

谷歌快速搜索给了我这个:

对于台式机: Mozilla/5.0 (Windows NT 10.0; <64-bit tags>) AppleWebKit/<WebKit Rev> (KHTML, like Gecko) Chrome/<Chrome Rev> Safari/<WebKit Rev> Edge/<EdgeHTML Rev>.<Windows Build>

对于移动设备: Mozilla/5.0 (WM 10.0; Android <Android Version>; <Device Manufacturer>; <Device Model>) AppleWebKit/<WebKit Rev> (KHTML, like Gecko) Chrome/<Chrome Rev> Mobile Safari/<WebKit Rev> Edge/<EdgeHTML Rev>.<Windows Build>

More Details

答案 1 :(得分:0)

基于EdgeDriver官方页面上的可用信息,我认为MS Edge没有提供更改用户代理的选项:https://docs.microsoft.com/en-us/microsoft-edge/webdriver#w3c-webdriver

此外,这是EdgeOptions的Java文档:https://seleniumhq.github.io/selenium/docs/api/java/org/openqa/selenium/edge/EdgeOptions.html,其中包含支持EdgeOptions的列表

相关问题