-
-
Notifications
You must be signed in to change notification settings - Fork 8.2k
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
[🐛 Bug]: Cookies management is not consistent #14884
Comments
@nvborisenko, thank you for creating this issue. We will troubleshoot it as soon as we can. Info for maintainersTriage this issue by using labels.
If information is missing, add a helpful comment and then
If the issue is a question, add the
If the issue is valid but there is no time to troubleshoot it, consider adding the
If the issue requires changes or fixes from an external project (e.g., ChromeDriver, GeckoDriver, MSEdgeDriver, W3C),
add the applicable
After troubleshooting the issue, please add the Thank you! |
From C# perspective it would be nice to:
|
I would consider this to be a common API change that needs to follow the deprecation process:
I don't think |
Current API is bad, it hides real reason under hood. Let's compare... I want to:
In all cases it throws/raises exception (in all programming languages?), like "Dear user, you are doing something wrong". Selenium should not be silent. #14545 shows why. When user deletes cookie via |
Taking a look at how users actually use this method in the wild: https://grep.app/search?q=GetCookieNamed%28 It looks like more often than not, people are just making an assertion that a cookie does not exist. In other words, following the WebDriver spec would require making users catch an exception (or more specifically, assert that an exception is thrown). If we don’t want a |
I don't think we are talking about Returning |
I think we should switch to using https://www.w3.org/TR/webdriver2/#get-named-cookie but maintain the backward compatibility. Throwing an exception if the cookie is not there would be a breaking change and might require users to update their assertions and tests. In my observation, end-users typically resist updating if there is a huge change and this might be that huge change. Selenium usage: https://plausible.io/manager.selenium.dev |
I agree that returning I like the approach of deprecating the method and creating a new one using the new endpoint. Like that, we will get feedback when people see the deprecation. Similarly to what is happening with |
Breaking changes like this can be expected in a new major release, so I would make this change (and others, potentially) in Selenium 5. This new major release can be a good opportunity to revamp/modernize the Selenium API across all the bindings. I know there is no official date for Selenium 5, and it is difficult to forecast, but this may happen in 2025, right? |
Now that I think of it, it might be a good idea to align the breaking change with a major release and revamp the API. |
I can take this up for Python bindings if its needed! |
Interesting important fact, which influences to the decision. According specification: driver.Manage().Cookies.DeleteCookieNamed("whoami"); // does not throw if not found
driver.Manage().Cookies.GetCookieNamed("whoami"); // throws if not found And now, from C# perspective, I am not glad that this API (according specification) is not aligned. I expected that we always can throw if an user is going to execute something with incorrect cookie. We can image that deleting of non-existing cookie is interpreted as success. So technically we can do nothing here, it is as is. The question now is only about |
What happened?
In C#:
But according spec it should throw an exception: https://www.w3.org/TR/webdriver2/#get-named-cookie
How can we reproduce the issue?
Relevant log output
Operating System
any
Selenium version
any
What are the browser(s) and version(s) where you see this issue?
any
What are the browser driver(s) and version(s) where you see this issue?
any
Are you using Selenium Grid?
No response
The text was updated successfully, but these errors were encountered: