Webdriver
I am using firefox hence I am downloading geckodriver to work with selenium. To set up the webdriver in the code do this:
from selenium import webdriver
driver_path = r"E:\webdriver\firefox\geckodriver.exe"
driver = webdriver.Firefox(executable_path=driver_path)
Install extension
To install an extension to the webdriver for each instance do this:
buster = r"E:\webdriver\firefox\buster_captcha_solver_for_humans-1.0.1-an+fx.xpi"
driver.install_addon(buster, temporary=True)
On every launch of the driver the extension will be installed, notice it is an absolute path of the file, I downloaded the xpi here.
Enable extension
To add the extension do this with the FirefoxProfile().
driver.profile = webdriver.FirefoxProfile()
driver.profile.add_extension(buster)
driver.profile.set_preference("security.fileuri.strict_origin_policy", False)
driver.profile.update_preferences()
If the extension was not installed before addition, selenium will throw an exception that the file specified is not found.