0

I am trying to scan the cookies of a specific page with selenium.

Unfortunately, the get_cookies() method can only get the first-party cookies, but I am more interested in the 3rd party cookies. As far as I can see the easiest solution could be reading Cookies database file of the browser. I tested my idea with the normal chrome browser and it works fine, I can find the 3rd party cookies with all their details in this file - \AppData\Local\Google\Chrome\User Data\Default\Cookies.

My problem that I can't figure out where the webdriver.chrome browser is saving the cookies on my local pc. Can anybody help with this?

2

Launching chrome URL chrome://appcache-internals/ will give app cache path. This gives a path from where the profile is loaded

So now we can use this trick in a browser launched in selenium and enter this URL. Will display the different profile path as shown in the image below.

enter image description here

When You navigate this path in your window file explorer you will get the browser profile stored in a path \AppData\Local\Temp\scoped_dir22252_1086323558\Default where scoped_dir22252_1086323558 is randomly created folder for each browser launch from selenium. Now you can get cookie file from this path

I hope this is your required output

You can automate this by launching the chrome URL chrome://appcache-internals/ and get the cookie filepath. Read the cookie file using SQLlite JDBC (since it is a SQLlite database) apply the SQL query and fetch the real data as you need

1
  • Jainam, thanks a lot for the very quick reply. It works perfectly Jul 13 '20 at 2:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.