为什么 Selenium 总是使用 Web 驱动程序创建临时 Firefox 配置文件,尽管我告诉它使用现有的?
根据这个答案,无法阻止 Selenium 使用 Web 驱动程序创建临时 Firefox 配置文件。但是使用 chromedriver 我可以做到这一点。那么为什么它对于 Firefox 是不同的。我检查了Selenium repo的FirefoxProfile.cs ,发现以下代码片段用于复制配置文件---
public void WriteToDisk()
{
this.profileDir = GenerateProfileDirectoryName();
if (!string.IsNullOrEmpty(this.sourceProfileDir))
{
FileUtilities.CopyDirectory(this.sourceProfileDir, this.profileDir);
}
else
{
Directory.CreateDirectory(this.profileDir);
}
this.InstallExtensions();
this.DeleteLockFiles();
this.DeleteExtensionsCache();
this.UpdateUserPreferences();
}
但是对于chorme来说没有这样的事情。
是不是因为 webdriver 安装了一个扩展(webdriver.xpi)来与 firefox 通信,而 chromedriver.exe 用于与 chrome 交互。
如果是这个原因,则在 3.0 版中,webdriver 正在使用 geckodriver.exe 与 firefox 进行通信。那么在 3.0 版之后,webdriver 将不再为 firefox 创建临时配置文件吗?
更新: 今天我玩了 webdriver v 3.0+,发现关闭 legacymode 的最新版本仍在生成名为rust_mozprofile.wUqPXh48avDR的临时配置文件。我的假设是这个临时配置文件是由用Rust编写的geckodriver.exe生成的
3 年前我使用过 chromedriver,但不确定chromedriver.exe 是否也会生成这种类型的临时文件。期待专家的解答...