0

Iam trying to use a specific Profile of my Chrome Browser.

I know you have to make use of the user-data-dir flag and add the path to your Profile.

Let's say I have a Profile named Profile 1.

I've tried doing this:

options = webdriver.ChromeOptions()
options.add_argument(r"user-data-dir=C:\Users\<username>\AppData\Local\Google\Chrome\User Data\Profile 1")

My problem is that Selenium by default Appends /Default to this value, therefore not finding a valid Profile.

So far the Only workaround I've found is to create a default folder in my Profile Directory, and then Copy all files in this directory to the Default folder I created.

When I do this, This runs perfectly. But I don't like the Idea of having to do this process.

Please how else can I solve this without having to duplicate my Profie Files? Thanks.

EDIT

The answer in that question doesn't work.. Whoever answered the question said to put Profile <num> as part of user-data-dir which DOESN'T work!

Isaac Frank
  • 351
  • 3
  • 12

1 Answers1

0

I fixed it, I thought user-data-dir takes the path to your profile, but I was wrong.

All I had to do was give user-data-dir my chrome data which is C:\Users\<username>\AppData\Local\Google\Chrome\User Data and then add profile-directory argument which takes name of the profile.

Final Code:

options = webdriver.ChromeOptions()
options.add_argument(r"user-data-dir=C:\Users\<username>\AppData\Local\Google\Chrome\User Data")
options.add_argument(r"profile-directory=Profile 1")
Isaac Frank
  • 351
  • 3
  • 12