ultrafunkamsterdam / undetected-chromedriver

Custom Selenium Chromedriver | Zero-Config | Passes ALL bot mitigation systems (like Distil / Imperva/ Datadadome / CloudFlare IUAM)
https://github.com/UltrafunkAmsterdam/undetected-chromedriver
GNU General Public License v3.0
9.53k stars 1.13k forks source link

Can't use user profiles #937

Open joshglens opened 1 year ago

joshglens commented 1 year ago

Hi all, I am trying to run a user profile that has a custom extension installed. However, when I run the WebDriver, it does not open with that profile and the extension is nowhere to be found. The entire of purpose of this is to use authenticated proxies, as every other method that I have tried (including loading an unpacked extension) doesn't work either as the extension never loads. I have made sure to close this profile before trying it.

My code is:

import undetected_chromedriver.v2 as uc
        chrome_options = uc.ChromeOptions()
        chrome_options.add_argument('--user-data-dir=C:\\Users\\Myname\\AppData\\Local\\Google\\Chrome\\User Data\\')
        chrome_options.add_argument('--profile-directory=Profile 6')
        driver = uc.Chrome(chrome_options=chrome_options)
        driver.get('https://httpbin.org/ip')

However my profile never loads. I'm not really sure what else I can do, and I also tried concatenating on Profile 6 to the user data dir string and throwing away the --profile-directory tag to no avail. Any help or additional suggestions would be appreciated. I am able to get this to work in the default selenium webdriver, but not with the undetected one.

mike1936 commented 1 year ago

Have you tried import undetected_chromedriver as uc? I have no problem with uc version 3.1.7 and chrome 108.0.5359.73

joshglens commented 1 year ago

I tried that as well but user directories and extensions don't seem to load at all. Everything else is working.

mike1936 commented 1 year ago

I tried that as well but user directories and extensions don't seem to load at all. Everything else is working.

Did the Chrome with specified profile launched when the script exected? Do you have any other sessions of non-headless Chrome, might be of the other profile, opened the time when the script starts to be executed?

For my case, when there are existing non-headless Chrome sessions, the script did launch the chrome with the specified profile but failed to return the driver. However, the scripts works when there are not any existing Chrome sessions the time when it starts.

joshglens commented 1 year ago

Hmm ok I can take a look at doing it without any additional Chrome sessions. I have never run it headless however.