代码之家  ›  专栏  ›  技术社区  ›  JohnWick

Selenium Firefox无法添加扩展名

  •  4
  • JohnWick  · 技术社区  · 6 年前

    我正在尝试将adblock的最新版本添加到具有Selenium的最新版本的firefox中。浏览器加载很好,没有异常,但是Adblock没有正确安装,当我检查浏览器中的扩展时,它不在那里。

    public static FirefoxDriver CreateFirefoxDriver(string driverPath, string binaryPath)
    {
        var profile = new FirefoxProfile();
        profile.AddExtension(@"C:\Users\david\source\repos\TestingApp\TestingApp\bin\Debug\selenium\browsers\firefox\extensions\adblock_plus-3.3.1-an+fx.xpi");
        profile.SetPreference("permissions.default.image", 2);
        var options = new FirefoxOptions();
        options.Profile = profile;
        var service = FirefoxDriverService.CreateDefaultService(driverPath);
        service.FirefoxBinaryPath = binaryPath;
        var driver = new FirefoxDriver(service, options);
        return driver;
    }
    

    当我用相同的xpi文件手动添加扩展名时,它可以正常工作。

    Selenium Nuget版本3.14.0(最新)

    GeckoDriver 0.23.0 Win64(最新)

    火狐62.0.3 64位(最新)

    adblock 3.3.1(最新)

    更新:

    尝试了最新版本的ublock xpi文件,也没有出现在我的扩展名中,无一例外地帮助我诊断出了什么问题。可以方便地手动添加相同的扩展名。

    我尝试使用firefox 61和60,但仍然有同样的问题。

    1 回复  |  直到 6 年前
        1
  •  3
  •   JohnWick    6 年前

    我终于解决了这个问题。我一直在尝试旧版本的火狐,最终58.0.2成功了。我似乎在他们的Github页面上找不到与GeckoDriver兼容的版本列表。