始终建议在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 );
但是,对于每个硒测试案例,将大量的87-90 mb配置文件信息通过http发送到集线器,从而减慢了测试用例的执行速度。
我尝试在json node config file中配置具有"Dwebdriver.firefox.profile=E:\\Firefox_Profile_Location":"",
属性的网格节点,如下所示。
{
"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个人资料'E:\ Firefox_Profile_Location' 在系统属性'webdriver.firefox.profile'中找不到
高级感谢有关如何从节点端配置firefox配置文件的任何帮助。
答案 0 :(得分:3)
我认为你必须使用firefox个人资料名称,而不是位置。
"webdriver.firefox.profile":"default"
进行操作
答案 1 :(得分:3)
您需要在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/