![](/img/trans.png)
[英]Unable to Launch Chrome and Firefox using selenium webdriver
[英]Firefox Webdriver unable to launch with extension
我正在使用 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 Developer edition 可以安装未签名的扩展。
我相信 Firefox 从版本 48 开始不再允许未签名的扩展,请参阅 mozilla.org/en-US/firefox/48.0/releasenotes
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.