I am new to using web driver but I have followed what was mentioned here (How can I launch Chrome with an unpacked extension?) and all that I could get from other web search.
I am trying to test an extension for chrome which I have developed but I haven't been able to figure out how to start chrome with extension loaded on it. Here is what I have till now and I would appreciate if someone could tell me the issue with the code (I was successful in launching Chrome using webdriver):
import time
from selenium import webdriver
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
browser = webdriver.Chrome() browser.get('http://seleniumhq.org/')
ChromeOptions options = new ChromeOptions();
options.addArguments("load-extension=C:\Users\mave\Desktop\Browser_Extension_Feature\extension_v5");
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability(ChromeOptions.CAPABILITY, options);
ChromeDriver driver = new ChromeDriver(capabilities);
time.sleep(15)
browser.quit()
I was finally able to figure out how to run an unpacked extension and would leave this code for anyone who has similar troubles in future:
import time
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
chrome_options = Options()
chrome_options.add_argument("load-extension=C:\Users\mave\Desktop\Browser_Extension_Feature\extension_v5");
browser = webdriver.Chrome(chrome_options=chrome_options)
browser.get('http://www.seleniumhq.org/')
time.sleep(5)
browser.quit()