【问题标题】:How to set the firefox profile at the node end in remote webdriver/grid configuration如何在远程 webdriver/grid 配置中的节点端设置 firefox 配置文件
【发布时间】:2023-03-07 15:20:01
【问题描述】:

始终建议在 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 测试用例都会减慢测试用例的执行速度。

我已经尝试在 json 节点配置文件中使用 "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 配置文件的帮助。

【问题讨论】:

  • 你为什么使用firefox配置文件夹而不是通过selenium代码设置配置文件?对firefox配置文件有什么要求?
  • 通过代码设置,必须通过http传输到节点端,需要时间。我想通过使用 conde 配置设置在节点端设置 firefox 配置文件配置来减少时间。

标签: selenium selenium-webdriver remotewebdriver selenium-grid2


【解决方案1】:

您需要在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/

【讨论】:

    【解决方案2】:

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

    "webdriver.firefox.profile":"default"
    

    看看thisthisthis

    如果您想知道如何创建个人资料,请关注 thisthis

    【讨论】:

      猜你喜欢
      • 2016-11-08
      • 2012-08-29
      • 2021-11-12
      • 1970-01-01
      • 2019-02-27
      • 1970-01-01
      • 1970-01-01
      • 2015-07-29
      • 1970-01-01
      相关资源
      最近更新 更多