Selenium WebDriver date handling after Selenium 4 W3C compliance transition
0 reputation · 18 Mar 2023, 03:52 UTC
Selenium WebDriver does not alter or normalize JavaScript Date values returned by executeScript; the browser supplies dates in its local timezone, which reflects the machine where the browser runs. Date strings sent to inputs via sendKeys are interpreted using the host locale settings, which can shift stored UTC values for controls such as datetime-local. Selenium 4 W3C compliance standardized timeout values in milliseconds, independent of timezone, but date-related logic remains dependent on the underlying browser clock.
There is no official Selenium utility for converting between local time and UTC. Projects typically rely on external libraries such as java.time or inline JavaScript snippets, leading to duplicated conversion code and inconsistency across language bindings. An unresolved design discussion concerns whether to add a timezone-aware helper, for example TimeZoneUtils to the Java bindings, with arguments for keeping clients lightweight versus reducing flaky cross-region tests.
The goal is to define a consistent approach for date-related assertions across agents with different system zones without introducing client bloat. What compatibility guarantees does Selenium intend to provide for date values returned by executeScript across browser locales? Is a timezone-aware helper class considered in scope for client bindings, or should normalization remain application responsibility? How should date-time-local input handling be documented for cross-region test reliability?