c# - Selenium Firefox 不添加扩展

标签 c# selenium

我正在尝试使用 Selenium 在 Firefox 上安装 ublock。问题是,扩展不会加载。浏览器加载正常,但不添加扩展。

FirefoxProfile profile = new FirefoxProfile();
profile.AddExtension("ublock_origin-1.17.4-an+fx.xpi");
FirefoxOptions options = new FirefoxOptions
{
    Profile = profile
};
IWebDriver driver = new FirefoxDriver(options);

我看过 this但我不想使用旧版本的 firefox,而且我还没有看到任何其他修复方法。

当前使用 v0.23.0 的 geckodriver for win64。

如何使用 selenium 为 firefox 添加扩展? (不使用旧版本)

最佳答案

尝试拆分选项部分,看看是否有所不同:

FirefoxProfile profile = new FirefoxProfile();
profile.AddExtension(*file path*);
FirefoxOptions options = new FirefoxOptions();
options.Profile = profile;
IWebDriver driver = new FirefoxDriver(options);

关于c# - Selenium Firefox 不添加扩展,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54164547/

相关文章:

c# - opencv houghlines2 linelength 是短的方式

c# - 在 C# 中使用 C++ dll

ruby - 提取由 Selenium WebDriver 在 Ruby 中启动的浏览器的 pid

java - 如何在不使用 jenkins 的情况下在 AWS 中运行本地 Selenium 测试脚本

c# - 将 BrowserRequestMode 设置为 NoCors 时未发送 HttpClient 授权 header

c# - 通过远程桌面连接时出现 IValueConverter NullReferenceException

c# - 为什么我的事件属性代码会导致堆栈溢出异常?

Java、Selenium、Chrome - 无法单击按钮,即使它似乎能够很好地找到它

java - 在缓存中未找到元素 - 也许页面自查找以来已发生更改 - 为什么?

javascript - 如何将属性设置为使用 selenium javascript?