我有最新版本的Firefox(62.0 32位)、Selenium(3.14.0.0)和gecko驱动程序(0.22.0 32位)。我的代码如下:
var firefoxProfile = new FirefoxProfile("XXX");
FirefoxDriverService service =
FirefoxDriverService.CreateDefaultService("XXX", "geckodriver.exe");
service.FirefoxBinaryPath = "XXX";
driver = new FirefoxDriver(service, new FirefoxOptions {
BrowserExecutableLocation = "XXX",
Profile = firefoxProfile,
UseLegacyImplementation = false },
new TimeSpan(0, 1, 30));
然而,由于以下错误,最后一行失败了:
System.IO.DirectoryNotFoundException:“找不到路径'C:\Users\XXX\AppData\Local\Temp\anonymous.5bbc89e65ae54c058b27b9027039414b.webdriver-profile.parentlock'的一部分。”
当您查看目录时,“anonymous.5bbc89e65ae54c058b27b9027039414b.webdriver-profile”文件夹不存在。
通过调用以下代码,我可以生成一个文件夹:
firefoxProfile.WriteToDisk();
然而,运行代码的最后一行之后,我仍然会得到相同的错误,只是在不同的“匿名”文件夹中。
通过启用“UseLegacyImplementation”可以解决这个问题,但这会引入其他问题,并且不是最佳选择。
查看周围,我没有在任何地方找到这条消息的参考资料,在Github上有一些相关内容,但与配置文件被忽略无关。
我曾经在较旧版本的库和Firefox上使用类似的代码,但出现了这个问题。是否有人对此有任何建议?