python selenium chrome incognito with extentions
extention manager is not enabled in incognito but it enabeld in normal chrome not incognito
i have activated developer mode
and add extention
this is my options in selenium chrome dirver
chrome_options = uc.ChromeOptions()
chrome_options.add_argument("start-maximized");
chrome_options.add_argument("--incognito")
path = os.path.dirname("this is my extention path")
chrome_options.add_argument(f"--load-extension={path}")
chrome_options.add_argument("--force-dev-mode-highlighting")
prefs = {"extensions.ui.developer_mode": True}
chrome_options.add_experimental_option("prefs", prefs)
chrome_options.add_argument("--system-developer-mode")
CodePudding user response:
My solution would be to set up a chrome profile with the extensions you want/need and enable them to be active in incognito as well (I've uploaded some pictures to show the path Extensions-> Manage extensions -> Details)
You can then pass some arguments as shown in the code below to start chromedriver in the profile you set up
source: https://stackoverflow.com/questions/52394408/how-to-use-chrome-profile-in-selenium-webdriver-python-3
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
options = webdriver.ChromeOptions()
options.add_argument(r"--user-data-dir=C:\path\to\chrome\user\data") #e.g.
C:\Users\You\AppData\Local\Google\Chrome\User Data
options.add_argument(r'--profile-directory=YourProfileDir') #e.g. Profile 3
driver = webdriver.Chrome(executable_path=r'C:\path\to\chromedriver.exe',
chrome_options=options)
driver.get("https://www.google.co.in")
Hope this helped