【发布时间】:2017-03-24 03:13:56
【问题描述】:
为什么 Selenium 总是使用 Web 驱动程序创建临时的 Firefox 配置文件,尽管我告诉它使用现有的配置文件?
根据this answer,无法阻止 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 的临时配置文件。我的假设是这个临时配置文件是由 geckodriver.exe 生成的,它写在Rust
我在 3 年前使用过 chromedriver,但不确定 chromedriver.exe 是否也会生成这种类型的临时文件。期待专家的解答...
【问题讨论】:
标签: selenium firefox webdriver selenium-chromedriver geckodriver