使用量角器在Firefox上设置用户代理并使用seleniumAddress不起作用

纳尔杜克

我想使用量角器和Firefox设置特定的用户代理。如果我在protractor.conf.js上使用directConnect,它将起作用:

//selenium-webdriver is installed via npm
var firefox = require('selenium-webdriver/firefox');
var firefoxProfile = new firefox.Profile();
firefoxProfile.setPreference("general.useragent.override", 'monitoring1152936086');

exports.config = {
    directConnect: true,

    capabilities: {
        'browserName': 'firefox',
        'firefox_profile': firefoxProfile
    },
    ...
}

但是,如果我使用seleniumAddress而不是directConnect,则它不起作用。测试工作正常,但未使用用户代理。我需要使用硒服务器。例如:

var firefox = require('selenium-webdriver/firefox');
var firefoxProfile = new firefox.Profile();
firefoxProfile.setPreference("general.useragent.override", 'monitoring1152936086');

exports.config = {
    seleniumAddress: 'http://localhost:4444/wd/hub',

    capabilities: {
        'browserName': 'firefox',
        'firefox_profile': firefoxProfile
    },
    ...
}

附带说明一下,我无法使用chrome,因为我正在尝试使用Firefox作为不太稳定的量角器和selenium-docker与chrome组合的解决方法(https://github.com/SeleniumHQ/docker-selenium/issues/ 87)。

有任何想法吗?谢谢!

灵魂

在直接连接的情况下,Protractor会自己创建浏览器,因此可以通过浏览器进行整体配置。在远程情况下,Protractor的控制较少,因为它正在连接到所启动的硒服务器webdriver-manager通过Firefox配置文件的正确时间是在webdriver-manager启动时,但Protractor当前不提供此功能。

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

使用量角器获取按钮上的禁用属性不起作用

来自分类Dev

使用量角器的Angular 2 e2e:by.model不起作用

来自分类Dev

使用量角器设置IEDriverServer位置

来自分类Dev

替代在Angular站点上使用量角器

来自分类Dev

使用量角器“期望”

来自分类Dev

在使用量角器元素函数选择的元素上使用 then() 后,黄瓜量角器超时

来自分类Dev

如何使用量角器API而不是配置文件设置量角器(v1.4.0)baseUrl?

来自分类Dev

如何使用量角器处理微调器

来自分类Dev

使用量角器在Firefox中打开文件网址

来自分类Dev

如何使用Chrome在MAC上使用量角器复制和粘贴?

来自分类Dev

如何使用量角器获取当前网址?

来自分类Dev

无法使用量角器webdriver-manager

来自分类Dev

mouseover元素无法使用量角器工作

来自分类Dev

使用量角器按className定位按钮

来自分类Dev

使用量角器测试无限滚动

来自分类Dev

如何使用量角器测试班级的存在

来自分类Dev

使用量角器测试链接颜色

来自分类Dev

如何使用量角器发送POST

来自分类Dev

在循环中使用量角器

来自分类Dev

使用量角器进行滑块测试

来自分类Dev

通过变量使用量角器链接元素?

来自分类Dev

在电子中使用量角器

来自分类Dev

使用量角器获取背景颜色

来自分类Dev

使用量角器退出的Safari WebDriver setTimeout

来自分类Dev

使用量角器获取跨度中的文本

来自分类Dev

如何使用量角器上传文件

来自分类Dev

无法使用量角器webdriver-manager

来自分类Dev

如何使用量角器测试angularjs应用

来自分类Dev

使用量角器获取当前时间