H4CKTRIK
H4CKTRIK

Reputation: 67

Chrome profile not loading with selenium

Here's my code:

from selenium import webdriver

options = webdriver.ChromeOptions() 
options.add_argument(r"user-data-dir=C:\Users\shahr\AppData\Local\Google\Chrome\User Data\Profile 1") #Path to your chrome profile
w = webdriver.Chrome(executable_path=r"C:\Program Files (x86)\chromedriver.exe", options=options)

I tried this from other StackOverFlow Answers, but it refuses to open the desired profile

Upvotes: 2

Views: 3478

Answers (1)

PDHide
PDHide

Reputation: 19989

chrom_options.add_argument("user-data-dir=C:\\Users\robert.car\\AppData\\Local\\Google\\Chrome\\User Data")

chrom_options.add_argument("profile-directory=Profile 1")

user-data-dir considers profile as default , and you don't have to specify that . If its something else specify it through profile-directory argument

Step to create a profile:

open : chrome://version in address bar

enter image description here

copy the user dir folder completely to eg c:\tmp\newdir

open the copied user data (newdir) and search for folder called Default . This is the profile folder.

rename the Default folder as "Profile 1"

Now to use this :

chrom_options.add_argument("user-data-dir=c:\\tmp\\newdir")

chrom_options.add_argument("profile-directory=Profile 1")

Upvotes: 6

Related Questions