Get cookies from incognito impossible

Hi there,

the new option to get Cookies from Chrome Dev Tools seems to fail if Chrome is started with „–incognito“.

Best
Mike

1 Like

Hi Mike,

while I don’t know for certain, I assume that this might be an intentional decision from the Chrome devs, to not give access to the cookie via API when running in “incognito” - this is just an assumption though.

Anyways, taking a step back: Is there a specific reason why you start Chrome with the incognito flag? Basically all new browser instances created by the Selenium nodes are a “blank paper” without any history, data, storage, cookie, etc. from previous sessions. Thus I’m wondering if you need the incognito mode at all?

Best,
Philipp

Hey Phillip,

Very valid point of yours. Though, I had thought the API kind of “has the high ground” over incognito mode.

I happen to notice that clearing cookies via a JavaSnippet Node and:

driver.manage().deleteAllCookies();

did only work for the site you currently navigated to but if you visited multiple domains, it does not apply for all. Navigating to chrome://settings/clearBrowserData and trying to delete the data that way doesn’t work as the clickable element can’t be found.

Therefore I attempted to fallback into incognito as when that webdriver gets terminated, so do it’s cookies. That, apparently, failed which is why I submitted this ticket.

Worth to note, I did some testing and, albeit being inconvenient, I re-initate the webdriver now. It adds a minuscule performance penalty but that’s the most straight way forward.

Cheers
Mike

Regarding clearing the cookies (you’ve been in touch about that via email) - this is something where a dedicated node would make sense. I’ve put it on the list for one of the next releases. I’ll keep you posted (also here in the thread)

Worth to note, I did some testing and, albeit being inconvenient, I re-initate the webdriver now. It adds a minuscule performance penalty but that’s the most straight way forward.

:+1: Indeed, that’s the best, recommended option for now (despite the performance overhead)

Have a good weekend,
Philipp

2 Likes

Update: Version 4.11.0 has an option to delete Cookies in the updated node:

Changelog:

2 Likes

Hi @qqilihq,

I am following up some of the many tickets which I reported in the past months. I happen to notice this might not have been resolved. Please see attached screenshot and updated workflow.

I have updated the workflow to utilize the updated nodes and tweaked it to give consent to all cookies and trigger a search just in case cookies become, for whatever reason, only available after navigation (browser tracking preventing mechanisms like Safari ITP).

Cheers
Mike

Hi Mike,

so if I understand correctly, this is with the Incognito Mode turned on – correct?

Based on my testing, it’s not possible to access the Cookies via CDT API. I am not sure if this is intended behavior or not by Chrome. Unfortunately I guess there’s not much we can do here from the Selenium Nodes perspective here, sorry!

[edit] Let me add this to the node documentation in the next update.

Best,
Philipp

Yes, in Incognito Mode no cookies could be retrieved via Chrome Developer Tools API (CDT API).

I tried to wrap my head around possible explanations. About CDT API I could not find something helpful. However, as explained in this thread:

Cookies might be in accessible because the process runs in another context (sandboxing?). Anyways, playing around with CookieStore API and good old document.cookie as well as the browser cookie setting, good old fashioned document.cookie always provides some data (albeit not http only).

To potentially utilize CookieStore, I dud a bit more:

Unfortunately it always resulted in undefined for getAllCookiesStores

I guess, since incognito mode might be a rather specific use case, we could call it a day. Wouldn’t oyu agree @qqilihq?

Edit
Hold on … I just noticed a severe mistake when retrieving cookies via CookieStore. Going to adjust my workflow once more to include all options available so far for completeness. However, I donät beleive it will change anything about not dying in virtuosity and rather sticking with the solution at hand you provided.

Edit #2
Here is evt. an example displaying a possible solution to inaccessible cookies in incognito mode:

best
Mike

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.