geckodriver icon indicating copy to clipboard operation
geckodriver copied to clipboard

Define WebExtensions in moz:firefoxOptions capabilities

Open titusfortner opened this issue 6 years ago • 20 comments

This is a feature request, feel free to close / redirect me if there's a better place to do this.

For reference, the Selenium Ruby code no longer seems to work for using Firefox::Profile#add_extension. I see that there's an endpoint to do this now, but this really seems like something that belongs in the capabilities information, not changed after opening the browser.

Ideally we wouldn't need "complicated" code to create a whole profile, we should be able to just encode the extension and pass it along in the capabilities like this:

{
    "capabilities": {
        "alwaysMatch": {
            "moz:firefoxOptions": {
                "extensions": [base_64_string_extension_one, base_64_string_extension_two]
            }
        }
    }
}

Alternatively, we (I) need to figure out how to fix the Ruby code. :)

titusfortner avatar Jan 19 '19 00:01 titusfortner

I don’t think I’m opposed to this idea, but it would be a fairly low priority since we already have POST /session/{session id}/addon/install.

andreastt avatar Jan 19 '19 13:01 andreastt

I feel this only adds confusion so I agree with Andreas. AFAIK also all other bindings make use of that specific end-point Andreas pointed out, and we haven't heard complains about it not working.

whimboo avatar Jan 21 '19 07:01 whimboo

@whimboo that's incorrect. As far as I know, Chrome is the only other browser that supports adding extensions, and it is definitely done in the capabilities as a path to the extension: http://chromedriver.chromium.org/extensions

As a tester I feel very strongly that everything related to the browser setup should be able to go into a config file and loaded when initializing the session. The solution you provide will force me to add conditionals to my test logic and likely hard code the values I need somewhere independent of the rest of my configuration code.

For example, I'm putting everything I need in a yaml, then pull values from it, then merge it in. This means favoring lookups over conditionals, reducing the complexity of the initialization code.

titusfortner avatar Jan 21 '19 16:01 titusfortner

I see. That would indeed be helpful then. Sorry, if I misunderstood it before.

In that case we can offer that extension property, and let geckodriver install the listed extensions right after creating the session by using the internal Addon:Install command.

whimboo avatar Jan 21 '19 19:01 whimboo

Was this issue ever resolved? I am able to specify adding an extension in chrome through chromeOptions like

Selenium::WebDriver::Remote::Capabilities.chrome({
                                                                               'chromeOptions' => {
                                                                                   'extensions' => [
                                                                                       Base64.strict_encode64(File.open(crx_path,'rb').read)
                                                                                   ],
                                                                                   prefs: prefs,
                                                                                   args: switches,
                                                                                   detach: true
                                                                               }
                                                                           })

and I would like to be able to do the same for firefoxOptions like:

Selenium::WebDriver::Remote::Capabilities.firefox({
                                                                                   "capabilities": {
                                                                                       "alwaysMatch": {
                                                                                           "moz:firefoxOptions": {
                                                                                               'extension' => [
                                                                                                   Base64.strict_encode64(File.open(xpi_path,'rb').read)
                                                                                               ],
                                                                                               args: switches,
                                                                                               prefs: prefs,
                                                                                               log: {
                                                                                                   "level": "trace"
                                                                                               }
                                                                                           }
                                                                                       }
                                                                                   }
                                                                               })

Any update would be much appreciated :)

jps042 avatar Jun 25 '19 16:06 jps042

No, it's not fixed but I filed https://bugzilla.mozilla.org/show_bug.cgi?id=1561841 to track this request internally.

whimboo avatar Jun 27 '19 07:06 whimboo

This one is open from an year, can we get any progress or any workaround ?

pandasm avatar Oct 01 '20 16:10 pandasm

We are currently not working on that due to other priorities. As workaround you can still use the vendor endpoint /session/{sessionId}/moz/addon/install to install an add-on.

whimboo avatar Oct 02 '20 09:10 whimboo

+1 to this feature. See this issue for some test examples that would benefit with the installation of web extensions with firefox options.

bonigarcia avatar Aug 14 '22 09:08 bonigarcia

Wrong link in @bonigarcia's comment: https://github.com/seleniumhq/selenium/issues/10946

titusfortner avatar Dec 20 '22 04:12 titusfortner

@titusfortner and @christian-bromann is https://bugzilla.mozilla.org/show_bug.cgi?id=1561841#c4 what you would like to see? Any other feedback from your side? Thanks.

whimboo avatar Jun 19 '23 16:06 whimboo

@nechaev-chromium given that Maxim isn't around right now maybe you could have a look at https://bugzilla.mozilla.org/show_bug.cgi?id=1561841#c4 and let me know if that is something you might consider as well for chromedriver in case Chrome requires such additional permissions? Thanks.

whimboo avatar Jun 26 '23 15:06 whimboo

@christian-bromann is https://bugzilla.mozilla.org/show_bug.cgi?id=1561841#c4 what you would like to see? Any other feedback from your side? Thanks.

What you have proposed sounds good to me. I think there is value having the ability to install a web extension on session start as well as during runtime as long as we find a common specification and browser handling for it.

christian-bromann avatar Jul 05 '23 05:07 christian-bromann

Previous code bases I've used, the configuration files and the browser specific conditionals were all applied and managed before the driver started. Obviously it can be worked around, but I've heard more complaints that Firefox can't install extensions in the capabilities than that chrome can't uninstall extensions.

titusfortner avatar Jul 05 '23 14:07 titusfortner

Thank you all for the feedback. Looks like we should find a common way to install webextensions via capabilities.

@nechaev-chromium given that Maxim isn't around right now maybe you could have a look at https://bugzilla.mozilla.org/show_bug.cgi?id=1561841#c4 and let me know if that is something you might consider as well for chromedriver in case Chrome requires such additional permissions? Thanks.

@mathiasbynens maybe you could have a look? Not sure whom else to ask around chromedriver's implementation while Maksim is out. Thanks.

whimboo avatar Aug 07 '23 11:08 whimboo

@sadym-chromium mind having a look at my last comment? Thanks!

whimboo avatar Jan 04 '24 13:01 whimboo

@whimboo next week, after my vacation. Or feel free to ping other our folks

sadym-chromium avatar Jan 04 '24 13:01 sadym-chromium

@whimboo next week, after my vacation. Or feel free to ping other our folks

@sadym-chromium ping - in case it slipped through. :)

whimboo avatar Feb 01 '24 20:02 whimboo

I'm not sure if it's possible to implement "extensionsInstallTemporarily": false in Chrome. WRT extensionsAllowPrivateBrowsing, is it still required, if we have UserContexts?

sadym-chromium avatar Feb 02 '24 12:02 sadym-chromium

Maybe lets follow-up on https://github.com/w3c/webdriver-bidi/issues/548 for further discussion given that this is basically a spec and not a driver issue.

whimboo avatar Feb 02 '24 13:02 whimboo