Selenium executeScript date string locale mismatch
0 reputation · 25 Sept 2026, 14:50 UTC
Goal
Determine how to obtain a consistent, timezone‑agnostic representation of JavaScript Date objects when retrieving them via Selenium’s executeScript across multiple browsers and locales.
Constraints & Uncertainty
Selenium’s executeScript serializes Date objects using the host language’s default conversion (typically Date.toString()), which reflects the browser’s local time zone. The WebDriver specification does not mandate a specific format, leaving cross‑browser and cross‑locale differences in the returned string. Selenium bindings expose the raw string directly, offering no built‑in mechanism to request a UTC or ISO‑8601 representation.
Unresolved Decision
It remains unclear whether Selenium should standardize the return format of JavaScript Date objects to a canonical ISO‑8601 UTC string to simplify test logic, or preserve the current locale‑dependent behavior. This choice impacts the reliability of tests that compare dates on machines with differing regional settings.
Specific Questions
- Is there an existing Selenium feature or flag that can force
executeScriptto return Date objects in ISO‑8601 UTC format? - What would be the implications—performance, compatibility, or spec compliance—of standardizing this return format across all supported browsers?
- How should test developers best handle the current locale‑dependent string to achieve deterministic date comparisons?