使用AddExtension时,无法使用firefox驱动程序硒加载扩展

时间:2019-09-03 19:59:22

标签: c# asp.net selenium geckodriver

我通过硒geckodriver创建了一个新的firefox配置文件,我试图通过内置的方法AddExtension(“ xpi path”)向该配置文件添加新的扩展名。我没有运行时错误,但是当浏览器打开时,好像没有安装任何扩展程序。实际上,当我检查“加载项”选项卡时,没有加载项/扩展名。

private void btnCreate_Click(object sender, EventArgs e) {

    var profile = new FirefoxProfile();
    profile.AddExtension( @ "C:\Users\danza\AppData\Roaming\Mozilla\Firefox\Profiles\vdxp2a78.kelley\extensions\hotspot-shield@anchorfree.com.xpi");
    var firefoxOptions = new FirefoxOptions { Profile = profile };
    var firefoxDriver = new FirefoxDriver(firefoxOptions);

    firefoxDriver.Navigate().GoToUrl("http://www.google.com");
}

下图是带有上面代码的加载项标签,证明实际上没有添加任何加载项。

enter image description here

0 个答案:

没有答案