Skip to content

As a Firefox extension developer, I would like to install a temporary extension from a folder #8357

@seanpoulter

Description

@seanpoulter

Edit: 2020-06-11 – ⚠️ This initial comment is not correct. I misunderstood the GeckoDriver API. I was looking at stale source code. 😓 With new knowledge and some guidance from the GeckoDriver team, I've proposed an approach to handle the "install addon" command from FirefoxDriver consistently for each language. See my long comment below.

--

🐛 Bug Report

We can't install a temporary extension in Firefox using the JavaScript or DotNet bindings. The implementation is inconsistent across the languages. The GeckoDriver API expects a path as a String but we're sending an addon. See mozilla/geckodriver - marionette.rs.

These two bindings need to be fixed:

Language Implementation Authors / CC
JavaScript javascript/node/selenium-webdriver/firefox.js#L637-L657 @kvetko, @jleyba
DotNet dotnet/src/webdriver/Firefox/FirefoxDriver.cs#L213-L227 @jimevans

These seem to be OK:

Language Implementation
Java java/client/src/org/openqa/selenium/firefox/FirefoxDriver.java#L235-L240
Python py/selenium/webdriver/firefox/webdriver.py#L247-L264
Ruby rb/lib/selenium/webdriver/firefox/bridge.rb#L34-L38

To Reproduce

Try to install an extension without building an .xpi or .zip file using dotnet and javascript bindings.

TODO - Script

Expected behavior

I expect to be able to install a temporary extension in Firefox:

  • From the JavaScript library using installAddon
  • From the DotNet library using InstallAddOn
    • Note 1: This method is not in those docs?!
    • Note 2: InstallAddOnFromFile is also made redundant

Test script or set of commands reproducing this issue

TODO - Include in example repo.

The steps to reproduce are:

  • Create a minimal extension
    • extension\manifest.json
      {
        "name": "Uh oh!",
        "description" : "Print a message to the console you may not see",
        "version": "0.1",
        "manifest_version": 2,
        "content_scripts": [
          {
            "matches": ["https://*.github.com/*"],
            "js": ["index.js"]
          }
        ]
      }
    • extension\index.js
      console.log('We did it! ⭐️');
  • Start Firefox and add an extension
    • javascript/example.js
      const { Builder, By } = require('selenium-webdriver');
      const { Options } = require('selenium-webdriver/firefox');
      
      (async () => {
      
        const options =
          new Options()
            .setPreference('extensions.htmlaboutaddons.recommendations.enabled', false);
      
        const builder =
          new Builder()
          .forBrowser('firefox')
          .setFirefoxOptions(options);
      
        const driver = builder.build();
      
        const isTemporaryAddon = true;
        driver.installAddon('../extension/', isTemporaryAddon);
      
        await driver.get('https://github.com/SeleniumHQ/selenium');
      
        // Expected: A message to be printed on the console
        // Expected: The temporary extension appears in about:debugging > This Firefox > Temporary Extensions
      
      })();
  • Install selenium-webdriver
    echo {} > package.json
    npm install --save-dev selenium-webdriver
  • Run
    node javascript/example.js

Environment

OS: macOS
Browser: Firefox
Browser version: 71.0
Browser Driver version: GeckoDriver for the last 2+ years
Language Bindings version: Latest
Selenium Grid version (if applicable): Not applicable

Questions

  1. Would you welcome a PR?
  2. Do you want the issue or PR split by language?

Metadata

Metadata

Assignees

Labels

C-dotnet.NET BindingsC-nodejsJavaScript Bindings

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions