Search code examples
pythonseleniumwebdriverselenium-chromedriverwebdriver-manager

python webdriver_manager chrome custom profile


How can I make webdriver_manager.chrome to use a custom chrome user profile?

I know for selenium webdriver I can specify like this:

options = Options()
options.add_argument(f'user-data-dir={script_path}\\User Data\\profile')
driver = webdriver.Chrome(executable_path=f'{script_path}\\chromedriver.exe', options=options)

But since I want to let chromedriver install the correct version on its own (because I sell my program to non python users) I am using the webdriver_manager module which looks like this:

driver = webdriver.Chrome(ChromeDriverManager().install())

Is there any way I could load a custom profile so that my log in data on websites is getting saved in my profile while using webdriver_manager?


Solution

  • You can use webdriver_manager.chrome and custom chrome user profile simultanously using the following solution:

    from selenium import webdriver
    from webdriver_manager.chrome import ChromeDriverManager
    
    options = Options()
    options.add_argument(f'user-data-dir={script_path}\\User Data\\profile')
    driver = webdriver.Chrome(executable_path=ChromeDriverManager().install(), options=options)
    driver.get('https://www.google.com/')