1

我在测试中使用 selenium FirefoxDriver 并并行运行这些测试 - 在每个线程中运行单独的 Firefox 实例。当我使用普通的 FireFox 时一切正常,但如果我想用便携式 Firefox 运行这些测试,第一个实例启动成功,但第二个、第三个等...失败并出现以下错误:

无法加载您的 Firefox 配置文件。它可能丢失或无法访问。

这就是我从代码中启动 Firefox 的方式:

var profile = new FirefoxProfileManager().GetProfile("default");
var firefoxBinary = new FirefoxBinary("Path to FireFoxPortable.exe");
_driver = new FirefoxDriver(firefoxBinary, profile);

任何想法我做错了什么?谢谢。

4

1 回答 1

3

Firefox 驱动程序正在尝试使用已在使用的配置文件启动 Firefox。这是不可能的,因为配置文件只能使用一次。多次手动启动 Firefox 时它似乎工作的原因是 Firefox 将使用已加载的配置文件重用现有正在运行的 Firefox 进程。

根据此信息,您的问题的解决方案是 1) 让 Firefox 驱动程序启动具有唯一/新配置文件的 Firefox,2) 更改您的代码,以便只需要一个 Firefox 驱动程序实例。

要使用多个实例启动 Firefox,请使用:firefox.exe -P "My Profile" -no-remote。不要认为 -no-remote 参数不应与启动的第一个配置文件一起使用,在您的情况下,这将是“默认”配置文件。更多信息在这里:http: //kb.mozillazine.org/Opening_a_new_instance_of_Firefox_with_another_profile

要使用不同的配置文件启动 Firefox Portable,如果前面的命令不适用于 Firefox Portable,请按照此处的说明操作:http: //portableapps.com/support/firefox_portable#second_profile

于 2014-12-25T12:43:34.140 回答