Open nddipiazza opened 6 years ago
Does it install correctly in Nightly?
yes. updated desc to include that. @andreastt
That probably means this isn’t a geckodriver issue, but a signing issue with your add-on.
@andreastt weird. i signed it through the addons.mozilla.org site (not self-signed). do you know if there is someone i can email about this?
I would file a bug in the WebExtensions
component in Bugzilla.
@andreastt is there a back-door way to install this extension? Like get the path of the profile then add the xpi to a folder and .... something like that?
You can try the /session/{session id}/moz/addon/install
endpoint: it takes a payload of a JSON Object with either the addon
field containing a string with the Base64-encoded addon, or a path
string to the location of the .xpi file.
After some investigation on IRC, @nddipiazza discovered this is a problem with installing an addon into the Firefox profile. Using the addon extension command mentioned in https://github.com/mozilla/geckodriver/issues/1225#issuecomment-374987968 works fine.
This is the workaround i was able to get going with:
driver = new FirefoxDriver(geckoDriverService, options);
URL geckoDriverServiceUrl = geckoDriverService.getUrl();
CloseableHttpClient client = HttpClientBuilder.create().build();
HttpPost httpPost = new HttpPost(geckoDriverServiceUrl.toString() + "/session/" + driver.getSessionId
() + "/moz/addon/install");
httpPost.setEntity(new StringEntity(String.format("{\"path\": \"%s\"}",
requestCounterFile.getAbsolutePath())));
CloseableHttpResponse response = client.execute(httpPost);
It would be good to have support for the addon installation/deletion extension directly in the Java client. Someone should submit a patch for it to Selenium.
We need to investigate, possibly file a bug against the web extensions component in Bugzilla, about why addons installed in the profile are considered unsafe. In relation to this, what is the observable difference between a profile where you manually install the addon and one that has a signed addon installed through the UI?
This is something that has worked for me:
//create service
FirefoxDriverService service = FirefoxDriverService.CreateDefaultService("./");
service.Host = "::1";
service.HideCommandPromptWindow = true;
service.Port = 4444;
service.Start();
//Create a FirefoxDriver instance (IWebdriver does not have InstallAddonFromDirectory method available.)
FirefoxDriver driver = new FirefoxDriver(service);
string extractedPath = @"C:\path\to\extensionfolderwheremanifestfileis"; // Replace with the path where you want to
//add unpacked extension (has worked better for this example. you can unzip using c# code in beforehand)
driver.InstallAddOnFromDirectory(extractedPath, true);
driver.Navigate().GoToUrl("https://www.example.com");
Thread.Sleep(5000);
// Close the browser
driver.Quit();
//stop geckodriver process instance you have started before.
Removed the options part of the code as per comment https://github.com/mozilla/geckodriver/issues/1225#issuecomment-1514454655
Dupe of issue #1225.
--allow-unsigned-xpi
is not an available command line argument for Firefox. As such it will not work to install this addon. See this comment in how to get the addon installed temporarily.
System
Testcase
Download https://addons.mozilla.org/firefox/downloads/file/897501/ajax_requestcounter-1.0-an+fx.xpi?src=dp-btn-primary
Add the extension from selenium:
Plugin will not install. Logs say:
This all works fine when running in dev-mode or nightly firefox.
Plugin works fine when installed manually in Firefox, or through the addons "add to firefox" link.
Trace-level log
https://gist.github.com/nddipiazza/3c42b705dd76a45d86fc944e48129045