5

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?

exec85
  • 447
  • 1
  • 5
  • 21

1 Answers1

7

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/')
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
  • `executable_path` is deprecated but [your other answer](https://stackoverflow.com/a/70099102/6243352) shows the way forward! – ggorlen Apr 13 '22 at 17:16