Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cookies set with StorageDomain.setCookies are not sent with Page.goto() #282

Open
jschneider opened this issue Aug 12, 2023 · 3 comments
Open
Labels
bug Something isn't working

Comments

@jschneider
Copy link
Contributor

Version

5.3.1-1170846

What happened?

Since 5.0 "pageSession.network.setCookie" is deprecated.
I tried to replace it with pageSession.storage.setCookies(

The cookies seem to be set. At least pageSession.storage.getCookies( returns plausible values.

But the set cookies are not sent to the server when calling page.goto.

Setting the cookie the "old" way works as expected.

Another thing: I could not get the "expires" value to work. Maybe this is related?

Reproduction and additional details

No response

Kotlin target platforms

JVM, Kotlin 1.8

@jschneider jschneider added the bug Something isn't working label Aug 12, 2023
@joffrey-bion
Copy link
Owner

joffrey-bion commented Aug 13, 2023

Hi @jschneider, thank you so much for the report.

Since 5.0 "pageSession.network.setCookie" is deprecated.

How did you infer this? This library generates domain APIs based on the official protocol definitions, and this includes deprecations. I double checked, and only the success boolean property of the SetCookieResponse type is deprecated at the moment in v5 of chrome-devtools-kotlin, which seems to match what the latest protocol version defines (see https://chromedevtools.github.io/devtools-protocol/tot/Network/#method-setCookie).

So you should still be able to use setCookie freely if that works better for you.

But the set cookies are not sent to the server when calling page.goto.

Regarding this, I'm not sure what the expected behaviour should be. The definition of the Storage.setCookies command is very vague (it's just "Sets given cookies.").
I'll investigate further what should happen here, but I'm not sure I'll be able to find an answer. These domain commands are simply "translated" to the Chrome DevTools Protocol format and sent over to Chrome (expect for the higher-level helpers), so I'm not sure there is anything that this library could do differently here.
The only potential source of problems that I see between this setCookies command and goto is the way we use browserContextId (using a different context ID might prevent cookies from being sent)

@jschneider
Copy link
Contributor Author

Ok, thanks mate!
I somehow misread the deprecated annotation. Sorry for that.

I will stick to network.setCookie().

@joffrey-bion
Copy link
Owner

I somehow misread the deprecated annotation. Sorry for that.

No problem at all. I'm glad your problem is solved (or rather not really a problem for you anymore).

Since the main topic of this issue is actually about the StorageDomain.setCookies function not behaving as expected, I will re-open this issue to track the investigation of how this command interacts with browser contexts and goto.

@joffrey-bion joffrey-bion reopened this Aug 13, 2023
@joffrey-bion joffrey-bion changed the title pageSession.storage.setCookies does not work Cookies set with StorageDomain.setCookies are not sent with Page.goto() Aug 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants