始终建议在 DesiredCapabilities 中设置 firefox 配置文件,并将其通过集线器运行的线路。像下面
DesiredCapabilities caps = DesiredCapabilities.firefox();
FirefoxProfile profile=new FirefoxProfile(new File("Local Path to firefox profile folder"));
caps.setCapability(FirefoxDriver.PROFILE, profile);
URL url = new URL("http://localhost:4444/wd/hub");
WebDriver driver= new RemoteWebDriver(url,caps );
但是通过 http 将巨大的 87-90 mb 配置文件信息发送到集线器,对于每个 selenium 测试用例都会减慢测试用例的执行速度。
我试过用
"Dwebdriver.firefox.profile=E:\\Firefox_Profile_Location":"",
配置网格节点json 节点配置文件中的属性,如下所示。{
"configuration":
{
.//Other Settings
.//Other Settings
.//Other Settings
"Dwebdriver.firefox.profile=E:\\Firefox_Profile_Location":"",
"maxSession":7,
"registerCycle":5000,
"register":true
},
"capabilities":
[
{"browserName":"firefox",
"seleniumProtocol":"WebDriver",
"maxInstances":5,
"platform":"VISTA"
}
]
}
但是使用上述配置运行会引发以下错误。
WebDriverException: Firefox profile 'E:\Firefox_Profile_Location' named in system property 'webdriver.firefox.profile' not found
高级感谢您提供有关如何从节点端配置 firefox 配置文件的任何帮助。
最佳答案
您需要在 capabilities
中提供配置文件对象作为 base64 编码的 zip:
var fs = require('fs');
capabilities: [
{
browserName: 'firefox',
seleniumProtocol: 'WebDriver',
maxInstances: 5,
platform: 'VISTA',
firefox_profile: new Buffer(fs.readFileSync("./profile.zip")).toString('base64')
}
]
此外,Firefox 会为给定的配置文件创建丢失的文件。因此,您应该根据需要在配置文件中保留必要的文件:
Preferences: user.js
Passwords: key3.db
logins.json
Cookies: cookies.sqlite
Certificate: cert8.sqlite
Extensions: extensions/
关于selenium - 如何在远程webdriver/grid配置中在节点端设置firefox配置文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39398117/