Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/selenium/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java Firefox Webdriver无法使用扩展启动_Java_Selenium_Webdriver_Selenium Firefoxdriver - Fatal编程技术网

Java Firefox Webdriver无法使用扩展启动

Java Firefox Webdriver无法使用扩展启动,java,selenium,webdriver,selenium-firefoxdriver,Java,Selenium,Webdriver,Selenium Firefoxdriver,我使用的是Selenium 3.3.1、geckodriver v0.15.0和Firefox 51.0.1(32位)。我想用一个未签名的浏览器扩展启动Firefox。我设法在Chrome上做到了这一点,但Firefox给我带来了一些麻烦。我必须运行webdriver的代码: public void startWebDriver (String browser) { if (browser == "Chrome") { ChromeOptions options

我使用的是Selenium 3.3.1、geckodriver v0.15.0和Firefox 51.0.1(32位)。我想用一个未签名的浏览器扩展启动Firefox。我设法在Chrome上做到了这一点,但Firefox给我带来了一些麻烦。我必须运行webdriver的代码:

    public void startWebDriver (String browser) {
    if (browser == "Chrome") {
        ChromeOptions options = new ChromeOptions();
        options.addArguments("--enable-devtools-experiments");
        options.addExtensions(new File(pathToChromeExtension));
        DesiredCapabilities capabilities = new DesiredCapabilities ();
        capabilities.setCapability(ChromeOptions.CAPABILITY, options);
        driver = new ChromeDriver(capabilities);
    }

    else if (browser == "Firefox") {
        System.setProperty("webdriver.gecko.driver", "c:\\Users\\...geckodriver.exe");
        FirefoxProfile firefoxProfile = new FirefoxProfile();
        String addonPath;
        addonPath = "\\whatever\\path\\to\\extension.xpi";
        File addonFile  = new File(addonPath);
        firefoxProfile.addExtension(addonFile);
        driver = new FirefoxDriver(firefoxProfile);
    }
当我运行此程序时,我收到以下错误:

org.openqa.selenium.WebDriverException:无法转换:功能[{moz:firefoxOptions={binary=Optional.empty,args=[],legacy=null,logLevel=null,prefs={},profile=org.openqa.selenium.firefox。FirefoxProfile@57a78e3},firefox_profile=org.openqa.selenium.firefox。FirefoxProfile@57a78e3}]

我试图在这里/互联网上找到类似的问题,但找不到任何真正相关的

我做错了什么?甚至可以让Firefox加载一个未签名的插件吗?请注意,我需要将此扩展添加为“临时加载项”,因为它没有签名等

谢谢您的回复!:)


干杯

我相信Firefox从48版开始就不再允许未签名的扩展,请参阅mozilla.org/en US/Firefox/48.0/releasenotes

使用Firefox开发者版来安装未签名的扩展


我相信Firefox从48版开始就不再允许未签名的扩展,看啊,好的,谢谢你的回答。我能不能把你的评论标记为回答,这样问题就可以回答了@LucasTierney必须先创建答案,然后才能将其标记为已接受。卢卡斯,很显然,提问者会喜欢这些观点,也可能是一个徽章,所以应该考虑建立一个答案。哈,好吧,我想我能做到……谢谢你们,先生们。我也投票支持你的答案,因为它是正确的,只是因为没有我的代表而看不见。