0

I'm using this code in order to "make" selenium-chrome to use my custom profile.

options = webdriver.ChromeOptions()
options.add_argument('--user-data-dir=C:\Users\imm\AppData\Local\Google\Chrome\User Data')
options.add_argument('--profile-directory=Profile 1')  
driver = webdriver.Chrome(executable_path=r"C:\Driver\chromedriver.exe", chrome_options=options)

But the opened chrome doesn't load the above profile, instead it's loading some temporary profile like below (which I get from chrome://version)

C:\Users\imm\AppData\Local\Temp\scoped_dir7692_1866581775\Default

And looking at the Command line section, I can see that selenium didn't pass the above arguments into the command line.

"C:\Program Files\Google\Chrome\Application\chrome.exe" --disable-background-networking --disable-client-side-phishing-detection --disable-default-apps --disable-hang-monitor --disable-popup-blocking --disable-prompt-on-repost --disable-sync --enable-automation --enable-blink-features=ShadowDOMV0 --enable-logging --force-fieldtrials --ignore-certificate-errors --load-extension="C:\Users\imm\AppData\Local\Temp\scoped_dir7692_281384323\internal" --log-level=0 --no-first-run --password-store=basic --remote-debugging-port=0 --test-type=webdriver --use-mock-keychain --user-data-dir="C:\Users\imm\AppData\Local\Temp\scoped_dir7692_1866581775" --flag-switches-begin --flag-switches-end data:,

Can someone tell me what I'm doing wrong? Thanks!

EagerToLearn
  • 675
  • 7
  • 24

1 Answers1

0

You need to use one argument

options = webdriver.ChromeOptions()
options.add_argument(r'user-data-dir=C:\Users\imm\AppData\Local\Google\Chrome\User Data\Profile 1')
driver = webdriver.Chrome(executable_path=r"C:\Driver\chromedriver.exe", chrome_options=options)

Notice you need to use r in front of the path or use \\ instead of one \.

Guy
  • 46,488
  • 10
  • 44
  • 88
  • Thanks for the answer, but I also already tried this. The problem remains the same. I tried every possible ways I found on the internet but no thing worked... – EagerToLearn Nov 28 '19 at 06:09
  • I think the problem is the `options ` object isn't actually passed into chrome driver. Because I tried add other arguments too but when checking the command line of `chrome://version`, they are not there. – EagerToLearn Nov 28 '19 at 06:14
  • @EagerToLearn the path in your question is with a single `\\`, not double. It is important. I tested this code, it works. – Guy Nov 28 '19 at 06:16
  • I know about the slash, I tested them all (when using \ only added r at the begining , or \\ if not using r) – EagerToLearn Nov 28 '19 at 06:25
  • and if you didn't believe me I can take screen shot showing that I ran your code but it didn't work. – EagerToLearn Nov 28 '19 at 06:26
  • Hi, I found out the code didn't work. Seems like selenium 3.6.0 is too old for Chrome v78, the solution is to upgrade Selenium to the newest version. – EagerToLearn Nov 29 '19 at 02:51