How to use specific Chrome profile with selenium python

208 views Asked by At

Please don't mark this is as duplicate first read my problem properly..

This is my code:

options = webdriver.ChromeOptions()
options.add_argument(r"--user-data-dir=C:\\Users\\Pranil.DESKTOP-TLQKP4G.000\\AppData\\Local\\Google\\Chrome\\User Data")
options.add_argument(r'--profile-directory=Profile 1')
browser = webdriver.Chrome(ChromeDriverManager().install(), options=options)
browser.get('https://web.whatsapp.com')

And this is the error I get:

selenium.common.exceptions.InvalidArgumentException: Message: invalid argument: user data directory is already in use, please specify a unique value for --user-data-dir argument, or don't use --user-data-dir

I tried the solutions given here: InvalidArgumentException: Message: invalid argument: user data directory is already in use error using --user-data-dir to start Chrome using Selenium

The problem is that the Default and Profile 1 are in the same directory User Data(Creating a new profile doesn't solve the problem as mentioned in above answer)..So if I run this script with my another chrome tab with 'Default' profile running in background this error appears..How can I make sure that this error goes away(I can't close the other chrome tabs with Default profile while running this script)

0

There are 0 answers