Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for Firefox WebExtensions #1181

Closed
zalmoxisus opened this issue Oct 21, 2015 · 5 comments
Closed

Support for Firefox WebExtensions #1181

zalmoxisus opened this issue Oct 21, 2015 · 5 comments
Labels

Comments

@zalmoxisus
Copy link

Mozilla introduced new WebExtensions API, which works already in Firefox Nightly. The old CPOWs extensions will be deprecated.

Trying to load an extension to Firefox Nightly, Seenium tries to find install.rdf, which doesn't exist anymore.

    var firefox = require('selenium-webdriver/firefox');
    var binary = new firefox.Binary('/Applications/FirefoxNightly.app/Contents/MacOS/firefox');
    var profile = new firefox.Profile();
    profile.addExtension('./build/firefox');
    var options = new firefox.Options()
      .setProfile(profile)
      .setBinary(binary);
    this.driver = new firefox.Driver(options);

Any plans to support the new extension format for firefox?

@jleyba
Copy link
Contributor

jleyba commented Oct 21, 2015

We haven't been able been able to get the webdriver.xpi extension (i.e. the FirefoxDriver) signed by Mozilla, and I don't believe we will. This particular feature may have to way for Marionette (Mozilla's WebDriver implementation).

@cmolocznik
Copy link

Below is a workaround I use written in Java. You just need to copy the entire .xpi to the "[PATH_TO_FIREFOX_PROFILE]/extensions" directory. Firefox will unpack and install automatically when launched via FirefoxDriver.

import org.openqa.selenium.firefox.internal.Extension;

import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.nio.file.StandardCopyOption;

public class FirefoxWebExtension implements Extension {
    private final File toInstall;

    public FirefoxWebExtension(File toInstall) {
        this.toInstall = toInstall;
    }

    @Override
    public void writeTo(File extensionsDir) throws IOException {
        if (!extensionsDir.exists()) {
            extensionsDir.mkdirs();
        }
        Files.copy(
                toInstall.toPath(),
                Paths.get(
                        extensionsDir.getAbsolutePath(),
                        toInstall.getName()
                ),
                StandardCopyOption.REPLACE_EXISTING
        );
    }
}

@alexristich
Copy link

@cmolocznik I'm new to Selenium, so I'm not too familiar with the project structure. Where would your workaround be placed in order to be functional?

@tobli
Copy link
Contributor

tobli commented Apr 24, 2017

See #3846

@jleyba
Copy link
Contributor

jleyba commented Apr 24, 2017

Fixed by 2f1df98

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

5 participants