Selenium: WebExtensions not installing on firefox

Created on 28 May 2017  路  24Comments  路  Source: SeleniumHQ/selenium

Meta -

OS:
Windows 10 64bit

Selenium Version:
selenium 3.4.0

Browser:

Firefox Version 53 using 0.16.1 geckodriver and

Steps to reproduce -

We are trying to install a new extension that we developed and it does not contain an install.rdf because this technique is now legacy as mentioned here .
The problem is that using the 0.16.1 geckodriver with selenium 3.4 does not seem to support this new kind of extensions and throws a : java.io.FileNotFoundException C:\Users(username)\AppData\Local\Temp\unzip3999903548710354720stream\install.rdf (The system cannot find the file specified)

Of course manually the extension installs. You can get it from here
I have asked at geckodriver github and they said it is a selenium issue

C-py D-firefox

Most helpful comment

I've submitted #4790 containing the fix for the Python bindings.

All 24 comments

For issues please provide a concise reproducible test case and describe what results you are seeing and what results you expect.

See CONTRIBUTING.md

Steps to reproduce:

  1. Download xpi from here (https://addons.mozilla.org/en-US/firefox/addon/mooltipass-extension/) right click and save as.
  2. Use it in code
        FirefoxProfile profile = new FirefoxProfile();

        profile.addExtension(new File("path/to/mooltipass_extension-1.1.81-an+fx-windows.xpi"));

        driver = new FirefoxDriver(profile);
  1. Run the project

Expected Result: addon is intalled

Actual Results: the exception below:

org.openqa.selenium.WebDriverException: Unable to convert: Capabilities [{moz:firefoxOptions={binary=Optional.empty, args=[], legacy=false, logLevel=null, prefs={}, profile=org.openqa.selenium.firefox.FirefoxProfile@7a67e3c6}, firefox_profile=org.openqa.selenium.firefox.FirefoxProfile@7a67e3c6}]
        at org.openqa.selenium.remote.BeanToJsonConverter.convertObject(BeanToJsonConverter.java:87)
        at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:128)
        at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:142)
        at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:82)
        at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:637)
        at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:250)
        at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:236)
        at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:137)
        at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:191)
        at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:108)
        at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:121)
        at mooltipass.automatedTest.config.WebDriverFactory.firefox(WebDriverFactory.java:74)
        at mooltipass.automatedTest.config.WebDriverFactory.createDriver(WebDriverFactory.java:173)
        at mooltipass.automatedTest.config.WebDriverFactory.get(WebDriverFactory.java:58)
        at mooltipass.automatedTest.config.BeforeAfter.getNewBrowser(BeforeAfter.java:44)
        at mooltipass.automatedTest.config.BeforeAfter.beforeScenario(BeforeAfter.java:22)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at cucumber.runtime.Utils$1.call(Utils.java:37)
        at cucumber.runtime.Timeout.timeout(Timeout.java:13)
        at cucumber.runtime.Utils.invoke(Utils.java:31)
        at cucumber.runtime.java.JavaHookDefinition.execute(JavaHookDefinition.java:60)
        at cucumber.runtime.Runtime.runHookIfTagsMatch(Runtime.java:223)
        at cucumber.runtime.Runtime.runHooks(Runtime.java:211)
        at cucumber.runtime.Runtime.runBeforeHooks(Runtime.java:201)
        at cucumber.runtime.model.CucumberScenario.run(CucumberScenario.java:40)
        at cucumber.runtime.junit.ExecutionUnitRunner.run(ExecutionUnitRunner.java:91)
        at cucumber.runtime.junit.FeatureRunner.runChild(FeatureRunner.java:63)
        at cucumber.runtime.junit.FeatureRunner.runChild(FeatureRunner.java:18)
        at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
        at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
        at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
        at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
        at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
        at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
        at cucumber.runtime.junit.FeatureRunner.run(FeatureRunner.java:70)
        at cucumber.api.junit.Cucumber.runChild(Cucumber.java:93)
        at cucumber.api.junit.Cucumber.runChild(Cucumber.java:37)
        at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
        at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
        at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
        at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
        at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
        at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
        at cucumber.api.junit.Cucumber.run(Cucumber.java:98)
        at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86)
        at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
        at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
        at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:678)
        at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
        at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)
      Caused by: org.openqa.selenium.WebDriverException: java.lang.reflect.InvocationTargetException
      Build info: version: '3.4.0', revision: 'unknown', time: 'unknown'
      System info: host: 'DESKTOP-308IKTK', ip: '10.0.0.83', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_131'
      Driver info: driver.version: FirefoxDriver
        at org.openqa.selenium.remote.BeanToJsonConverter.convertObject(BeanToJsonConverter.java:214)
        at org.openqa.selenium.remote.BeanToJsonConverter.convertObject(BeanToJsonConverter.java:142)
        at org.openqa.selenium.remote.BeanToJsonConverter.convertObject(BeanToJsonConverter.java:188)
        at org.openqa.selenium.remote.BeanToJsonConverter.convertObject(BeanToJsonConverter.java:85)
        ... 52 more
      Caused by: java.lang.reflect.InvocationTargetException
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at org.openqa.selenium.remote.BeanToJsonConverter.convertObject(BeanToJsonConverter.java:197)
        ... 55 more
      Caused by: org.openqa.selenium.WebDriverException: java.io.FileNotFoundException: C:\Users\mohamed\AppData\Local\Temp\unzip4496712249998374393stream\install.rdf (The system cannot find the file specified)
      Build info: version: '3.4.0', revision: 'unknown', time: 'unknown'
      System info: host: 'DESKTOP-308IKTK', ip: '10.0.0.83', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_131'
      Driver info: driver.version: FirefoxDriver
        at org.openqa.selenium.firefox.internal.FileExtension.readIdFromInstallRdf(FileExtension.java:142)
        at org.openqa.selenium.firefox.internal.FileExtension.writeTo(FileExtension.java:61)
        at org.openqa.selenium.firefox.FirefoxProfile.installExtensions(FirefoxProfile.java:424)
        at org.openqa.selenium.firefox.FirefoxProfile.layoutOnDisk(FirefoxProfile.java:402)
        at org.openqa.selenium.firefox.FirefoxProfile.toJson(FirefoxProfile.java:374)
        at org.openqa.selenium.firefox.FirefoxOptions.toJson(FirefoxOptions.java:557)
        ... 60 more
      Caused by: java.io.FileNotFoundException: C:\Users\mohamed\AppData\Local\Temp\unzip4496712249998374393stream\install.rdf (The system cannot find the file specified)
        at java.io.FileInputStream.open0(Native Method)
        at java.io.FileInputStream.open(FileInputStream.java:195)
        at java.io.FileInputStream.<init>(FileInputStream.java:138)
        at java.io.FileInputStream.<init>(FileInputStream.java:93)
        at sun.net.www.protocol.file.FileURLConnection.connect(FileURLConnection.java:90)
        at sun.net.www.protocol.file.FileURLConnection.getInputStream(FileURLConnection.java:188)
        at org.apache.xerces.impl.XMLEntityManager.setupCurrentEntity(Unknown Source)
        at org.apache.xerces.impl.XMLVersionDetector.determineDocVersion(Unknown Source)
        at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
        at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
        at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
        at org.apache.xerces.parsers.DOMParser.parse(Unknown Source)
        at org.apache.xerces.jaxp.DocumentBuilderImpl.parse(Unknown Source)
        at javax.xml.parsers.DocumentBuilder.parse(DocumentBuilder.java:205)
        at org.openqa.selenium.firefox.internal.FileExtension.readIdFromInstallRdf(FileExtension.java:98)
        ... 65 more
      

Make sure that you have created the profile you are using

Win +R
firefox.exe -p

Check this or,

Webdriver driver= new FirefoxDriver();
driver.get(url);

Use this.

subscribing to this issue... we really need it fixed :(

any ETA? :(

Root Cause :

This issue is occuring because selenium install firefox extension as described below

  1. Extract the .xpi file to some temporary location
  2. Generate the extension installation folder path using the extension id
  3. Copy xpi extracted contents to installation folder

Now, as your extension is built with WebExtensions API so instead of __install.rdf__ you have __manifest.json__ and hence it fails to extract extension id.

In order to fix this we need to add support to read application id from __manifest.json__ and also as add-on ID is not a mandatory property in __manifest.json__ , so we need to check if an add-on id is present in __manifest.json__ or not. If it's present then use the provided id, else generate a unique id by your own or using other fields such as name,version etc

References

extension_installation_issue

I'm adding labels for other bindings because obviously this needs to be fixed everywhere.

I don't know if that would be a workaround for now, but Ruby supports installing addons after initialization of GeckoDriver:

driver = Selenium::WebDriver.for(:firefox)
driver.install_addon 'path_to.xpi'

Ruby landed in c32eb80c56a713f41dc2fffd99ed07d3bcd9c508

When would it be possible to get this fixed in the python binding? Thank you.

@natasasdj Pull requests are welcome! You can use driver.install_addon and driver.uninstall_addon as a workaround now.

I've submitted #4790 containing the fix for the Python bindings.

Installing webextensions works with the js bindings and is covered by this test:

https://github.com/SeleniumHQ/selenium/blob/master/javascript/node/selenium-webdriver/test/firefox/firefox_test.js#L103

Any news when the c# fix will be pushed into the nuget package?

Not able to add an extension with geckodriver. Here are my below config:
Selenium 3.5.1
Gecko driver: 17
firefox version 54
OS: MAC Osx

The error I am facing
org.openqa.selenium.WebDriverException: Unable to convert: Capabilities [{acceptInsecureCerts=true, browserName=firefox, moz:firefoxOptions={binary=Optional.empty, args=[], legacy=null, logLevel=null, prefs={}, profile=org.openqa.selenium.firefox.FirefoxProfile@738dc9b}, version=, platform=ANY, firefox_profile=org.openqa.selenium.firefox.FirefoxProfile@738dc9b}]

Please suggest any workaround. Thanks!

Merged in 4756fd1. Thank you for the contribution.

When will this bugfix appear in NuGet package?

When this bug will be fixed for python?

Is there a PR for the python bindings for this or should I provide one? @AutomatedTester @barancev @lmtierney ?

There is #4790.

When this bug will be fixed for python?

There are PRs that fixes this at #4790, #5069 and #6463, which of the latter seem to be closer to merging than the former.

This has been addressed by #6463 and should be available in the next release.

Not able to add an extension with geckodriver. Here are my below config:
Selenium 3.5.1
Gecko driver: 17
firefox version 54
OS: MAC Osx

The error I am facing
org.openqa.selenium.WebDriverException: Unable to convert: Capabilities [{acceptInsecureCerts=true, browserName=firefox, moz:firefoxOptions={binary=Optional.empty, args=[], legacy=null, logLevel=null, prefs={}, profile=org.openqa.selenium.firefox.FirefoxProfile@738dc9b}, version=, platform=ANY, firefox_profile=org.openqa.selenium.firefox.FirefoxProfile@738dc9b}]

Please suggest any workaround. Thanks!

Try doing the same test with a developer version of Firefox. That seemed to work for me.

Was this page helpful?
0 / 5 - 0 ratings