12

始终建议在 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:找不到系统属性“webdriver.firefox.profile”中命名的 Firefox 配置文件“E:\Firefox_Profile_Location”

高级感谢有关如何从节点端配置 firefox 配置文件的任何帮助。

4

2 回答 2

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/
于 2016-09-15T22:23:35.837 回答
3

我认为您必须使用 Firefox 配置文件名称而不是位置。

"webdriver.firefox.profile":"default"

看看这个这个这个

如果您想知道如何创建个人资料,请遵循

于 2016-09-14T18:17:32.080 回答