How to select Chrome extensions to enable when using Selenium [duplicate] How to select Chrome extensions to enable when using Selenium [duplicate] selenium selenium

How to select Chrome extensions to enable when using Selenium [duplicate]


You can accomplish this using ChromeOptions class or DesiredCapabilities. For that you have to have the .crx file and load that with driver instance.

import osfrom selenium import webdriverfrom selenium.webdriver.chrome.options import Optionsexecutable_path = "path_to_webdriver"os.environ["webdriver.chrome.driver"] = executable_pathchrome_options = Options()chrome_options.add_extension('path_to_extension')driver = webdriver.Chrome(executable_path=executable_path, chrome_options=chrome_options)driver.get("http://stackoverflow.com")driver.quit()

Code taken from @alecxe answer here and more details about ChromeOptions and DesiredCapabilities here