How to install extension permanently in geckodriver

Solution 1:

Note: OP didn't specify a language, so this answer is for Python. The other Selenium WebDriver language bindings have similar mechanisms for creating profiles and adding extensions.


You can install the Extension each time you instantiate the driver.

First, download the extension (XPI file) you want from: https://addons.mozilla.org.

Then, in your code... create a FirefoxProfile() and use the add_extension() method to add the extension. Then you can instantiate a driver using that profile.

For example, this will launch Firefox with a newly created profile containing the "HTTPS Everywhere" extension:

from selenium import webdriver

profile = webdriver.FirefoxProfile() 
profile.add_extension(extension='https_everywhere-2019.1.31-an+fx.xpi')
driver = webdriver.Firefox(firefox_profile=profile) 

Solution 2:

You need to launch geckdriver with an exisitng profile by specifying the profile path of firefox

For python you can do it by this:

profile = FirefoxProfile('/home/student/.mozilla/firefox/gwi6uqpe.Default') // change this path
browser = webdriver.Firefox(firefox_profile=profile)

For C# you can do this:

string path = @"C:\Users\username\AppData\Local\Mozilla\Firefox\Profiles\myi5go1k.default";
FirefoxProfile ffprofile = new FirefoxProfile(path);
Driver = new FirefoxDriver(ffprofile);