我使用的是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:无法转换:Capabilities [{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}]
我试图在这里/在互联网上找到similair问题,但找不到真正相关的东西...
我做错了什么?甚至可以让Firefox加载一个未签名的插件?请注意,我需要将此扩展名添加为“临时插件”,因为它没有签名等...
任何回复表示赞赏! :)
干杯
答案 0 :(得分:0)
我相信Firefox已停止允许从版本48开始的未签名扩展,请参阅mozilla.org/en-US/firefox/48.0/releasenotes
答案 1 :(得分:0)
使用Firefox开发人员版可以安装未签名的扩展名。