1

I am trying to launch chrome specific profile using python selenium

I try this code

option.add_argument("user-data-dir=C:\\Users\\Gamer\\AppData\\Local\\Google\\Chrome\\User Data\\Profile 2")

but it's open chrome as a Guest

2 Answers 2

1

You can try with options like this :

from selenium import webdriver

options = webdriver.ChromeOptions()
options.add_argument("user-data-dir=C:\\Users\\Gamer\\AppData\\Local\\Google\\Chrome\\User Data\\Profile 2")
driver = webdriver.Chrome(executable_path=r'C:\path\to\chromedriver.exe', options=options)
driver.get("https://www.google.co.in")
Sign up to request clarification or add additional context in comments.

6 Comments

i see this, SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 16-17: truncated \UXXXXXXXX escape
Can you share the entire stack trace ?
sry, i didn't understand (i am not 100% english) did you mean the code ?
i try to do that but same my code is options = Options() options.add_argument(r"user-data-dir=C:\Users\Gamer\AppData\Local\Google\Chrome\User Data\Profile 2") web = webdriver.Chrome('./chromedriver.exe', options=options)
|
0

You can try it as below, For the profile location type chrome://version in the URL bar and check for Profile Path

from selenium import webdriver
from selenium.webdriver.chrome.options import Options

options = webdriver.ChromeOptions()
options.add_argument(r"user-data-dir=C:\\Users\\Gamer\\AppData\\Local\\Google\\Chrome\\User Data")
options.add_argument(r'--profile-directory=Profile 2')
driver = webdriver.Chrome(executable_path=r'C:\path\to\chromedriver.exe', chrome_options=options)
driver.get("https://www.google.co.in")

Also, try to close the main browser instance while running it for multiple time else it might display the Exception

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.