Unable to load firefox Add ons in python selenium
add_extension()
is a method on FirefoxProfile
, not WebDriver
:
profile = webdriver.FirefoxProfile()profile.add_extension(extension=self.path_fire_fox_file)self.driver = webdriver.Firefox(profile)
Plus, I'm not sure if you really need that time.sleep(5)
call - try without wasting 5 seconds.
While I agree with alecxe, it only worked for some of my extensions. I managed to install all of them successfully (from .xpi files) with install_addon()
which is called on already instantiated webdriver.Firefox
:
driver = webdriver.Firefox(executable_path='path_to_geckodriver')# Path to .xpi file needs to be an absolute path. I think it must be a string too.driver.install_addon(str(Path('extensions/some_extension.xpi').absolute()))driver.get("about:addons") # One step closer to see all extensions at glance