2

When trying to add FoxyProxy extension to Firefox driver like so:

from selenium.webdriver import FirefoxProfile, DesiredCapabilities
from selenium import webdriver

profile =FirefoxProfile()
firefox_capabilities = DesiredCapabilities.FIREFOX
firefox_capabilities['marionette'] = False
profile.add_extension(extension='res/foxyproxy@eric.h.jung.xpi')
profile.set_preference("extensions.logging.enabled", True)
driver = webdriver.Firefox(profile,capabilities=firefox_capabilities)

Everything seems fine but then when window opens I see that FoxyProxy was not installed, also the browser console gives a following message:

1566128038983   addons.xpi-utils    DEBUG   New add-on foxyproxy@eric.h.jung installed in app-profile
Blocklist::loadBlocklist: blocklist is disabled
1566128039076   addons.xpi-utils    WARN    Add-on foxyproxy@eric.h.jung is not correctly signed. 2
1566128039076   addons.xpi-utils    WARN    addMetadata: Add-on foxyproxy@eric.h.jung is invalid: Error: Extension foxyproxy@eric.h.jung is not correctly signed(resource://gre/modules/addons/XPIDatabase.jsm:2452:17) JS Stack trace: addMetadata@XPIDatabase.jsm:2452:17
processFileChanges@XPIDatabase.jsm:2809:26
checkForChanges@XPIProvider.jsm:2728:55
startup@XPIProvider.jsm:2265:12
callProvider@AddonManager.jsm:193:31
_startProvider@AddonManager.jsm:569:5
startup@AddonManager.jsm:725:14
startup@AddonManager.jsm:2797:26
observe@addonManager.js:65:29

Which means that the extension is not signed correctly. The xpi file was acquired buy copying it directly from my normal profiles extension folder so I do not understand why this warning shows up? And is it in fact the source of failed installation.

CodeSamurai777
  • 3,285
  • 2
  • 24
  • 42

1 Answers1

0

Just banged my head against this one for long time. add_extension isn't very bright. It automatically passes unpack=True to _install_extension, and unpacking undoes any signing efforts, hence the error.

Try this directly calling _install_extension with unpack=False instead:

from selenium.webdriver import FirefoxProfile, DesiredCapabilities
from selenium import webdriver

profile =FirefoxProfile()
firefox_capabilities = DesiredCapabilities.FIREFOX
firefox_capabilities['marionette'] = False
profile._install_extension('res/foxyproxy@eric.h.jung.xpi', unpack=False)
profile.set_preference("extensions.logging.enabled", True)
driver = webdriver.Firefox(profile,capabilities=firefox_capabilities)