Problem when using custom Chrome profile from different location
Asked Answered
E

1

2

After I created a custom profile "SeleniumBot" I try to open it using Selenium ChromeDriver and Selenium ChromeOptions. It works just fine for the default path in AppData/Google/Chrome/User Data/SeleniumBot. I get problems when I try to copy the profile folder inside the program/project files and use the --user-data-dir agrument and i put the path to the copy of the profile. The problem is the browser does not start with the stored/saved account to login in gmail.

All solutions I read are about making opening a profile and making one.

My proram needs to run this profile with this particular account on any machine that will not have this custom profile created inside the User Data directory. Any suggestions on how to solve this problem?

Existent answered 19/3, 2021 at 9:41 Comment(0)
L
4

I will organize this answer into two scenarios. One if you're using the default chrome profile (shown as: C:\Users\david\AppData\Local\Google\Chrome\User Data\Default) or an added chrome profile (shown as: C:\Users\david\AppData\Local\Google\Chrome\User Data\Profile 1)

You can check this by typing chrome://version in your search bar.

Case 1: You are using a default profile.

  1. Navigate to that profile path. Should be something like C:\Users\david\AppData\Local\Google\Chrome\User Data\Default.

  2. Copy and paste that entire folder into whatever place you would like.(ex: D:\Chrome_Profiles). Your directory would look something like this: D:\Chrome_Profiles\Default

  3. Chromedriver automatically adds "Default" to the end of the options.add_argument(r"user-data-dir= part. Thus, you would just use:

    options.add_argument(r"user-data-dir=D:\Chrome_Profiles") driver.get("https://www.facebook.com")

and you'll see it works just fine.

2nd case: you're using another chrome profile (noted by Profile 1, Profile 2, etc. in chrome://version)

  1. Navigate to that profile path. Should be something like C:\Users\david\AppData\Local\Google\Chrome\User Data\Profile 1.

  2. Copy and paste that entire folder into whatever place you would like.(ex: D:\Chrome_Profiles). Your directory would look something like this: D:\Chrome_Profiles\Profile 1

  3. Change Profile 1 to Default. Your directory will look something like this: D:\Chrome_Profiles\Default

  4. Chromedriver automatically adds "Default" to the end of the options.add_argument(r"user-data-dir= part. Thus, you would just use:

    options.add_argument(r"user-data-dir=D:\Chrome_Profiles") driver.get("https://www.facebook.com")

I tested this myself just now and it works. Please let me know if this solved your problem. Thanks!

Laclos answered 19/3, 2021 at 9:58 Comment(4)
I'm in debug mode right now, after I create new ChromeDriver(options) I can't see in bin/Debug any chrome directory i used search in all project folders. Can you tell me more detailed where to find this "chrome" folder? Is it where the .exe(binaries) runs?Existent
Can you show me the directories/subdirectories?Laclos
Hey, I tried it myself. It's because Chromedriver automatically adds "Default" to the end. For instance, if I copied a chrome profile here: user-data-dir=D:\Chrome_Profiles\Default, it wouldn't work. Thus, you would have to delete the "Default" at the end, making it as such: user-data-dir=D:\Chrome_Profiles. It will work then. Please see if that solved the issue for you. I will edit the answer to make it reflect this comment.Laclos
Did this help you?Laclos

© 2022 - 2024 — McMap. All rights reserved.