【发布时间】:2016-08-28 16:04:57
【问题描述】:
我在一个设置中,我需要使用 Firefox Portable 38.7.1 进行我的 Selenium 测试(版本 2.53.0)。一切正常,但现在我需要配置代理。
我在默认配置文件中配置了它(它保存在${FF_PORTABLE_PATH}/Data/profile/prefs.js)
user_pref("network.proxy.http", "proxyHost");
user_pref("network.proxy.http_port", proxyPort);
user_pref("network.proxy.share_proxy_settings", true);
user_pref("network.proxy.ssl", "proxyHost");
user_pref("network.proxy.ssl_port", 51854);
user_pref("network.proxy.type", 1);
...
手动启动浏览器时,效果很好。但是,当被 Selenium 触发时,会创建和使用一个匿名配置文件,它没有我的代理设置。
我尝试在启动节点时指定配置文件。
一开始我试过using -Dwebdriver.firefox.profile:
java -jar selenium-server-standalone-2.53.0.jar -role node -Dwebdriver.firefox.profile=default
然后我尝试使用默认配置文件作为模板using -firefoxProfileTemplate:
java -jar selenium-server-standalone-2.53.0.jar -role node -firefoxProfileTemplate "${FF_PORTABLE_PATH}/Data" -nodeConfig ...
我还创建了一个新配置文件(使用ProfilistPortable 插件)并在节点启动时指定它(使用webdriver.firefox.profile-参数)。
在所有情况下,Selenium 节点都会使用“干净”的匿名配置文件打开 Firefox Portable,而无需我的代理设置。
谁能帮助我如何让这个设置与 Firefox Portable 一起工作?我真的不需要单独的个人资料。只要我可以强制 Selenium 使用配置了代理的配置文件,我就可以了。
这是我的节点配置:
{
"capabilities": [
{
"browserName": "firefox",
"version": "38.7.1",
"firefox_binary": "${FF_PORTABLE_PATH}\\FirefoxPortable.exe",
"platform": "WINDOWS",
"maxInstances": 1,
"seleniumProtocol": "WebDriver"
}
],
"configuration": {
"proxy": "org.openqa.grid.selenium.proxy.DefaultRemoteProxy",
"maxSession": 1,
"port": 5550,
"host": "ip",
"register": true,
"registerCycle": 5000,
"hubHost": "localhost",
"hubPort": 4440
}
}
我在上面的例子中使用了 ${FF_PORTABLE_PATH}。实际上,这个(完全合格的)路径在我的所有设置中都是硬编码的。
【问题讨论】:
-
我很伤心看到没有答案,因为我也遇到了麻烦..
-
@martin - 你找到解决方案了吗?
-
@CodeRocker 很遗憾我没有,抱歉
标签: selenium firefox selenium-grid selenium-firefoxdriver portable-applications