Selenium 在使用 JSON Wire Protocol 时不使用 webdriver.firefox.profile

Selenium not using webdriver.firefox.profile when using JSON Wire Protocol

我启动了配置文件管理器并创建了一个名为 foo 的新配置文件。我在启动 firefox 时选择默认使用此配置文件,然后启动 firefox 并关闭它。

我使用参数 -Dwebdriver.firefox.profile=foo 启动 selenium。我在服务器的输出中看到这已被设置为默认配置文件。

但是,当通过 NightwatchJS(JSON 有线协议)启动新会话时,会为会话创建一个匿名配置文件,而不是使用预先创建的配置文件。我也尝试传递 firefox_profile 所需的功能,但这似乎没有什么不同。

这是一个已知问题吗?是否有某种解决方法?

您应该在 nighwatch.json 配置文件中定义目标配置文件:

解决方案 1

在全局硒配置中:

http://nightwatchjs.org/guide#selenium-settings

"selenium" : {
  ...
  "cli_args" : {
    "webdriver.firefox.profile" : "foo"
  }
},

解决方案 2

在浏览器配置中:

按照本文档的第 3 部分进行操作:https://github.com/beatfactor/nightwatch/wiki/Enable-Firebug-in-Firefox-for-Nightwatch-tests

3) Configure Nightwatch to use the new profile

Open your nightwatch.json file and in your test_settings add a property called > firefox_profile under the desired environment (e.g. "default"). Set this property to the new firefox profile name you have created in step 1 (e.g. "foo").

"test_settings" : {
   "default" : {
     ...
     "firefox_profile" : "foo",
     ...
   }
}

小心!它是 不是 一个 "desiredCapability" 参数 ;-)