我在我的测试中使用 selenium FirefoxDriver 并并行运行这些测试——在每个线程中运行单独的 Firefox 实例。当我使用普通的 FireFox 时一切正常,但如果我想用 Firefox portable 运行这些测试,第一个实例启动成功,但第二个、第三个等等...失败并出现此错误:
Your Firefox profile cannot be loaded. It may be missing or inaccessible.
这是我从代码启动 Firefox 的方式:
var profile = new FirefoxProfileManager().GetProfile("default");
var firefoxBinary = new FirefoxBinary("Path to FireFoxPortable.exe");
_driver = new FirefoxDriver(firefoxBinary, profile);
知道我做错了什么吗? 谢谢。
最佳答案
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 .
关于c# - 如何使用 Selenium FirefoxDriver 启动多个 Firefox portable 实例,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27647148/