kazurayam / chromedriverfactory

A Java library that enables you to launch Selenium ChromeDriver using an existing user Profile. That let you to carry cookies over multiple HTTP sessions via user Profile.
0 stars 0 forks source link

Cannot find profile #60

Open danpoleary1 opened 3 months ago

danpoleary1 commented 3 months ago

I have a profile in chrome "onmicrosoft" and it is associated to directory "Profile 3" but when I run, I get:

ChromeUserProfile of "onmicrosoft" is not found in :
["{\"userProfile\":\"Guest\",\"userDataDir\":\"C:\\Users\\hcuser\\AppData\\Local\\Google\\Chrome\\User Data\",\"profileDirectoryName\":\"Guest Profile\"}","{\"userProfile\":\"Person 1\",\"userDataDir\":\"C:\\Users\\hcuser\\AppData\\Local\\Google\\Chrome\\User Data\",\"profileDirectoryName\":\"Default\"}","{\"userProfile\":\"Person 2\",\"userDataDir\":\"C:\\Users\\hcuser\\AppData\\Local\\Google\\Chrome\\User Data\",\"profileDirectoryName\":\"Profile 1\"}","{\"userProfile\":\"Person 2\",\"userDataDir\":\"C:\\Users\\hcuser\\AppData\\Local\\Google\\Chrome\\User Data\",\"profileDirectoryName\":\"Profile 2\"}","{\"userProfile\":\"Person 2\",\"userDataDir\":\"C:\\Users\\hcuser\\AppData\\Local\\Google\\Chrome\\User Data\",\"profileDirectoryName\":\"Profile 3\"}","{\"userProfile\":\"Person 2\",\"userDataDir\":\"C:\\Users\\hcuser\\AppData\\Local\\Google\\Chrome\\User Data\",\"profileDirectoryName\":\"Profile 4\"}","{\"userProfile\":\"Person 2\",\"userDataDir\":\"C:\\Users\\hcuser\\AppData\\Local\\Google\\Chrome\\User Data\",\"profileDirectoryName\":\"System Profile\"}"]

Output of chrome://version for that profile:

<html>
<body>
<!--StartFragment-->
Google Chrome | 122.0.6261.129 (Official Build) (64-bit) (cohort: Stable)
-- | --
Revision | f18a44fedeb29764b2b5336c120fdd90ef1a3f5c-refs/branch-heads/6261@{#1057}
OS | Windows 10 Version 22H2 (Build 19045.4170)
JavaScript | V8 12.2.281.22
User agent | Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36
Command Line | "C:\Program Files\Google\Chrome\Application\chrome.exe" --flag-switches-begin --flag-switches-end
Executable Path | C:\Program Files\Google\Chrome\Application\chrome.exe
Profile Path | C:\Users\hcuser\AppData\Local\Google\Chrome\User Data\Profile 3

<!--EndFragment-->
</body>
</html>
kazurayam commented 3 months ago

The message is formatted badly, hard to read. So I manually rewrote as follows

ChromeUserProfile of "onmicrosoft" is not found in :
[
    {"userProfile":"Guest","userDataDir":"C:\\Users\\hcuser\\AppData\\Local\\Google\\Chrome\\User Data","profileDirectoryName":"Guest Profile"},
    {"userProfile":"Person 1","userDataDir":"C:\\Users\\hcuser\\AppData\\Local\\Google\\Chrome\\User Data","profileDirectoryName":"Default"},
    {"userProfile":"Person 2","userDataDir":"C:\\Users\\hcuser\\AppData\\Local\\Google\\Chrome\\User Data","profileDirectoryName":"Profile 1"},
    {"userProfile":"Person 2","userDataDir":"C:\\Users\\hcuser\\AppData\\Local\\Google\\Chrome\\User Data","profileDirectoryName":"Profile 2"},
    {"userProfile":"Person 2","userDataDir":"C:\\Users\\hcuser\\AppData\\Local\\Google\\Chrome\\User Data","profileDirectoryName":"Profile 3"},
    {"userProfile":"Person 2","userDataDir":"C:\\Users\\hcuser\\AppData\\Local\\Google\\Chrome\\User Data","profileDirectoryName":"Profile 4"},
    {"userProfile":"Person 2","userDataDir":"C:\\Users\\hcuser\\AppData\\Local\\Google\\Chrome\\User Data","profileDirectoryName":"System Profile"}
]

It seems that you have 3 userProfile named Guest, Person1, Person2. It seems that you actually do no have a userProfiled named onmicrosoft.

I do not see what's happening to you.

kazurayam commented 3 months ago

I have Chrome v123 now. I looked at /Users/username/Library/Application Support/Google/Chrome folder. I got puzzled. It seems that Chrome has changed its internal data structure that represents what we call "User Profile".

The data structure of User Profin in Chrome v123 is different from what I saw previously when I developed the chromedriverfactory project initially (around Chrome v143). I have no idea when and how the change has been made. Of course, Google would not publish the internal data structure of Chrome.

This project "chromedriverfactory" did a sort of reverse-engineering. I looked at the files in /Users/username/Library/Application Support/Google/Chrome folder trying to find a User Profile "Picasso" is recorded in the folder. And I made a wild guess how the User Profile is recorded. My guess is fragile, will be broken easily.

Does Google provides any public JavaScript API that enable users to retrieve information about user profiles? Is it possible to ask Chrome to tell the Path of a custom profile "Picasso"? --- I don't know. I searched Google for it, but not successful.

danpoleary1 commented 3 months ago

It is strange. I did try using "Profile 3" as the profile name, which is the directory for "onmicrosoft" profile listed in the Chrome UI. Same results.

I will try a few more things to see if I can get it to find the correct profile and path.

kazurayam commented 3 months ago

In Emacs, I did M-x grep-find for the /Users/username/Library/Application Support/Google/Chrome folder with key Picasso, which is the name of a custom User Profile. I got 2 hits.

In the Local_State file under the Chrome folder, I found a clue:

{
  ...
    "profile": {
    "info_cache": {
      "Default": {
        "active_time": 1711106965.087676,
        "avatar_icon": "chrome://theme/IDR_PROFILE_AVATAR_0",
        "background_apps": false,
        "default_avatar_fill_color": -1844265,
        "default_avatar_stroke_color": -9545651,
        "first_account_name_hash": 327,
        "force_signin_profile_locked": false,
        "gaia_given_name": "Kazuaki",
        "gaia_id": "116298576906500294506",
        "gaia_name": "Kazuaki Urayama",
        "gaia_picture_file_name": "Google Profile Picture.png",
        "hosted_domain": "NO_HOSTED_DOMAIN",
        "is_consented_primary_account": true,
        "is_ephemeral": false,
        "is_using_default_avatar": false,
        "is_using_default_name": false,
        "last_downloaded_gaia_picture_url_with_size": "https://lh3.googleusercontent.com/a/ACg8ocIWM4oOqV3OeJ_Uq6lLGYkCaA0pwwZmLSzp-8auzJ2i8Q=s256-c-ns",
        "managed_user_id": "",
        "metrics_bucket_index": 1,
        "name": "Kazuaki",
        "profile_highlight_color": -1844265,
        "signin.with_credential_provider": false,
        "use_gaia_picture": true,
        "user_accepted_account_management": false,
        "user_name": "kazuaki.urayama@gmail.com"
      },
      "Profile 17": {
        "active_time": 1711106965.203889,
        "avatar_icon": "chrome://theme/IDR_PROFILE_AVATAR_26",
        "background_apps": false,
        "default_avatar_fill_color": -1319433,
        "default_avatar_stroke_color": -9426516,
        "force_signin_profile_locked": false,
        "gaia_given_name": "",
        "gaia_id": "",
        "gaia_name": "",
        "hosted_domain": "",
        "is_consented_primary_account": false,
        "is_ephemeral": false,
        "is_using_default_avatar": true,
        "is_using_default_name": false,
        "managed_user_id": "",
        "metrics_bucket_index": 14,
        "name": "Picasso",                              <=== THIS IS IT!!
        "profile_highlight_color": -1319433,
        "signin.with_credential_provider": false,
        "user_name": ""
      }
    },
    "last_active_profiles": [
      "Default",
      "Profile 17"
    ],
    "last_used": "Profile 17",
    "metrics": {
      "next_bucket_index": 15
    },
    "picker_shown": true,
    "profile_counts_reported": "13355536720985432",
    "profiles_created": 18,
    "profiles_order": [
      "Default",
      "Profile 17"
    ],
    "show_picker_on_startup": false
  },

With this info, I can find that the User Profile "Picasso" has the Profile foldr Profile 17 under the /Users/username/Library/Application Support/Google/Chrome

kazurayam commented 3 months ago

I don't know if the Local State file was there in the previous versions of Chrome as well.

kazurayam commented 3 months ago

released the v0.7.0

ChromeDriverFactory refers to the "Chrome/UserData/Local State" file to look up the pairs of Cache Directory name and User Profile name managed by Chrome.

kazurayam commented 3 months ago

@danpoleary1

Please try the latest version v0.7.3

kazurayam commented 3 months ago

I will wait for @danpoleary1 to have a look at this

kazurayam commented 3 months ago

See also #76 "a quick method that returns a list of ChromeUserProfiles in JSON"