I have the following code that connects to a Remote Webdriver and installs an extension
options = webdriver.FirefoxOptions()
options.set_preference('intl.accept_languages', 'en,en-US')
options.add_argument('--log-level=3') # Not logs will be displayed.
options.add_argument('--mute-audio') # Audio is muted.
options.add_argument('--enable-webgl-draft-extensions')
options.add_argument('--disable-infobars') # Disable popup
options.add_argument('--disable-popup-blocking') # and info bars.
profile = webdriver.FirefoxProfile()
profile.add_extension('/path/to/tampermonkey.xpi')
driver = webdriver.Remote("http://127.0.0.1:4445/wd/hub", options=options, browser_profile=profile)
But when I go into the browser, the extension was never installed. Am I misunderstanding how to install extension in geckodriver?
For Firefox, you should not use
add_extension, as mentioned in this issue:However,
install_addonis only available for local webdrivers. A simple workaround is required when using remote webdrivers, as mentioned in this issue. The trick requires you to change:to
The full code should be something like below:
I have opened a pull request to the Selenium Docs to clarify such usages.