-
-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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]: toString() method of Cookie.class outputs expiry time in 12-hour format with no AM/PM indication #13927
Comments
@ricky-murphy, 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! |
I think the timezone must be GMT to match the HTTP date format. |
@ricky-murphy The format and the timezone is fixed with d1b84e4, thanks for reporting! |
This issue has been automatically locked since there has not been any recent activity since it was closed. Please open a new issue for related bugs. |
What happened?
REPRODUCTION STEPS
EXPECTED RESULTS
Expiry date is printed in either 24-hour format or a 12-hour format with an AM/PM indicator
ACTUAL RESULTS
Expiry date is printed in a 12-hour format with no AM/PM indicator.
IMPACT
What this means is that an expiry time of "4:23:21 PM EDT" gets printed as "04:43:21 EDT" - implying "04:43:21 AM EDT".
This can make debugging interesting, and intermittently breaks use cases that use the toString() method to save cookies. But works fine in the morning. Doing a Google search for
reveals many examples like this where that method is used to save cookies. This will result in valid cookies being marked as expired in the afternoon.
There are multiple workarounds
ROOT CAUSE/FIX
The toString() method of common/src/java/org/openqa/selenium/Cookie.java formats the expiry as "EEE, dd MMM yyyy hh:mm:ss z"
Least disruptive fix would likely be to switch the hour format from "hh" (Hour in am/pm (1-12)) to "HH" (Hour in day (0-23))
Fixed code would look like
: "; expires=" + new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss z").format(expiry))
How can we reproduce the issue?
Relevant log output
Operating System
Windows 10
Selenium version
4.20.0
What are the browser(s) and version(s) where you see this issue?
Firefox 125.0.3, likely affects all browsers
What are the browser driver(s) and version(s) where you see this issue?
FirefoxDriver, likely affects all drivers as the cookie class is common to all of them. expiry was added to toString() method in 2.34.0
Are you using Selenium Grid?
No
The text was updated successfully, but these errors were encountered: