为firefox设置配置文件错误:无法转换功能

时间:2017-05-23 11:58:29

标签: selenium selenium-webdriver

要为firefox添加扩展程序,我尝试了代码:

System.setProperty("webdriver.gecko.driver", "C:\\Users\\abc\\Downloads\\geckodriver-v0.14.0-win64\\geckodriver.exe");    
String path = "C:\\Program Files (x86)\\Mozilla Firefox\\browser\\extensions\\{972ce4c6-7e08-4474-a285-3208198ce6fd}.xpi";
FirefoxProfile profile = new FirefoxProfile();
profile.addExtension(new File(path));            
driver = new FirefoxDriver(profile);

错误截图:

enter image description here

3 个答案:

答案 0 :(得分:0)

我在您的代码中发现您使用的是geckodriver-v0.14.0-win64

此问题已在最新版本的geckodriver中修复。

您可以从以下链接下载最新的geckodriver:

https://github.com/mozilla/geckodriver/releases

让我知道它是否有效。

答案 1 :(得分:0)

以下是您的问题的答案:

您尝试使用的扩展程序的名称 SELECT * FROM donations INNER JOIN mymembers on (donations.userid = mymembers.id) Order By donations.userid Firebug

问题: {972ce4c6-7e08-4474-a285-3208198ce6fd}.xpi 答案是“否”。

所以根据MDN“Firefox 48 :(从Firefox 46推送).Firebook for Desktop的发行版和Beta版将不允许安装未签名的扩展,没有覆盖。

因此,要安装未签名的扩展,您需要将firefox降级到47.x版本。

如果这回答您的问题,请告诉我。

答案 2 :(得分:0)

使用以下代码创建Firefox配置文件并更正geckodriver的属性路径:

        System.setProperty("webdriver.firefox.marionette", "C:\\geckodriver.exe");
        FirefoxProfile profile = new FirefoxProfile();
        profile.setAcceptUntrustedCertificates(false);
        profile.setAssumeUntrustedCertificateIssuer(true);
        DesiredCapabilities dc = DesiredCapabilities.firefox();
        dc.setCapability(FirefoxDriver.PROFILE, profile);
        driver = new FirefoxDriver(dc);

享受:)

相关问题