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

michael.g reported that cookie file in a pre-populated user-data-dir is initialized when Chrome starts #52

Closed kazurayam closed 6 months ago

kazurayam commented 1 year ago

https://forum.katalon.com/t/open-browser-with-custom-profile/19268/29

quote from his post:

michel.g 1h Hello kazurayam,

I understand the history of your contributions, yet my issue is possibly not bound to using an older version. I’ve read the latest version: the logic, for the part which I’m investigating, is the same.

My question is more general.

a) I have a Chrome profile “MyProfName”, whose data is in the normal “User Data” file structure: AppData\Local\Google\Chrome\User Data\Profile 21

b) I get this “Profile 21” directory copied into a temporary file structure: AppData\Local\Temp\MyUserData12345etc\MyProfName

The original Cookies file (SQLite database) has been copied as part of the process:

From: AppData\Local\Google\Chrome\User Data\Profile 21\Network\Cookies To: AppData\Local\Temp\MyUserData12345etc\MyProfName\Network\Cookies c) The copy has been successful: If I had stopped execution after the copy (breakpoint), I can verify its contents using my favorite SQLite tool.

d) Then the ChromeDriver is instantiated, with various options including: [window-size=1024,768, --no-sandbox, disable-infobars, disable-gpu, disable-dev-shm-usage, --disable-features=ChromeWhatsNewUI, --ignore-certificate-errors, user-data-dir=C:\Users\MICHEL~1\AppData\LocalTemp\MyUserData12345etc, profile-directory=MyProfName]

e) Later on, after the WebDriver is created, I observe that the Cookies file has been altered. The SQLite database has been emptied. :astonished:

My question is: How to tell the WebDriver instantiation process not to empty the Cookies?

I’ve looked for switches/options/preferences that would drive this behavior, but I haven’t found.

Any idea?

Cheers, –Michel

kazurayam commented 6 months ago

Previously Chrome with --headless option had a bug that it can not handle cookies properly. As of version 109, Chrome with --headless=new option can handle cookies properly.

See the following Stackoverflow post:

c# - Getting Cookies from Headless ChromeDriver - Stack Overflow I have examined the --headless=new option. It worked for me.

kazurayam commented 6 months ago

see #72