C# Selenium Firefox不添加扩展

C# Selenium Firefox不添加扩展,c#,selenium,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 }; IWeb

我正在尝试使用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);
我已经看过了,但我不想使用旧版本的firefox,我也没有看到任何其他的修复方法

目前正在使用适用于win64的geckodriver的v0.23.0


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

尝试拆分选项部分,看看这是否有区别:

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

使用Selenium 4.X并使用
FirefoxDriver.InstallAddOnFromFile
方法,而不是
FirefoxOptions.AddExtension

看起来您并没有给出您的应用程序的完整路径extension@SnR也尝试了完整路径,没有更改。您使用的是哪个版本的selenium webdriver?@PrasanthG最新版本,v3.141.0。Selenium webdriver已经15个月没有更新了,这个问题已经问了12个月了。您可以试试处于alpha阶段的Selenium 4.x。只需使用FirefoxDriver类并调用InstallAddOnFromFile并传递扩展名的文件路径。它应该是有效的这是字面上和我一样,我的只是简化。它不会有任何区别。这个方法在版本3和4.x中都不存在?
FirefoxProfile profile = new FirefoxProfile();
FirefoxOptions options = new FirefoxOptions
{
    Profile = profile
};
IWebDriver driver = new FirefoxDriver(options);
firefoxDriver.InstallAddOnFromFile("ublock_origin-1.17.4-an+fx.xpi"); // Dear Wizard, this is the magic