How to load extension within chrome driver in selenium with python
To open chrome browser with any extension you need to use the add_extension()
method through an instance of chrome.options
class and you can use the following solution :
from selenium import webdriverfrom selenium.webdriver.chrome.options import Optionschrome_options = Options()chrome_options.add_extension(r'C:\path\to\extension.crx')driver = webdriver.Chrome(chrome_options=chrome_options, executable_path=r'C:\Utility\BrowserDrivers\chromedriver.exe')driver.get('https://www.google.co.in')print("Page Title is : %s" %driver.title)driver.quit()
References
You can find the relevant documentation in:
You can find a couple of relevant discussions in:
Use this code to fetch extensions
from selenium.webdriver.chrome.options import Optionsfrom selenium.webdriver.common.desired_capabilities import DesiredCapabilitiesChromeOptions options = new ChromeOptions();options.addExtensions(new File("/pathtoChromeextension.crx")); //adding DesiredCapabilities capabilities = new DesiredCapabilities();capabilities.setCapability(ChromeOptions.CAPABILITY, options);ChromeDriver driver = new ChromeDriver(capabilities);
Use below to get crx file http://crxextractor.com/ from your extension id which is omghfjlpggmjjaagoclmmobgdodcjboh
Simplest answer as far as I'm aware - manifest in subfolder of location you've referenced (e.g. 3.28.2_0' or whatever the latest version of extension is...)
This assumes you're using 'options.add_argument('--load-extension=')...
For options.add_extension('reference crx file .crx')