Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Selenium | Loading multiple extensions into Selenium's ChromeDriver, only receiving the last defined

I'm currently attempting to load two extensions into Selenium's ChromeDriver. Ublock Origin and Ghostery. Looking online, the solution for this tends to just be as simple as adding an argument for each extension. However, when I attempt to add these two arguments, it will only load the second defined extension and ignore the first.

from selenium import webdriver
from selenium.webdriver.chrome.options import Options

PATH = "C:\Program Files (x86)\chromedriver.exe"

ublock = r'C:\Users\Senuvox\PycharmProjects\Projects\SeleniumExtensions\1.35.2_0'
ghostery = r'C:\Users\Senuvox\PycharmProjects\Projects\SeleniumExtensions\8.5.5_0'

options = Options()
options.add_argument('load-extension=' + ghostery)
options.add_argument('load-extension=' + ublock)
options.add_argument('--ignore-ssl-errors=yes')
options.add_argument('--ignore-certificate-errors')

driver = webdriver.Chrome(PATH, options=options)
driver.create_options()
driver.get("http://www.google.com")

When one runs this script, as stated before, only Ublock will load into the Selenium chrome browser. Similarly, if I swap the order so Ublock is first and Ghostery is second, only Ghostery will load.

Additionally I have attempted to one-line it by adding commas in-between the two extension variables. Unfortunately, this provides an error as add_argument takes only two positional arguments.

Any insights on how I might solve this would be greatly appreciated!

like image 321
Senuvox Avatar asked Oct 15 '25 16:10

Senuvox


1 Answers

#use .crx file path of extension
options.add_extension('C:\\Users\\ublock-1.35.2_0.crx')
options.add_extension('C:\\Users\\ghostery-8.5.5_0.crx')

useful resource

like image 79
vishalvvr Avatar answered Oct 17 '25 04:10

vishalvvr



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!