I am trying to launch chrome specific profile using python selenium?

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

Upvotes: 1

Views: 127

Answers (2)

YaDav MaNish
YaDav MaNish

Reputation: 1352

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

Upvotes: 0

cruisepandey
cruisepandey

Reputation: 29362

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")

Upvotes: 1

Related Questions