Is webdriver capable to run a browser with a time, date or time zone?



  • Is webdriver capable to run a browser with a faked time, date or time zone? Such ability would be highly useful for my automation purposes. Yet, I did not find any such ability in the webdriver documentation. I guess such functionality is quite sophisticated as it would require to intercept and feedback altered Kernel calls. Therefore not necessarily included into webdriver - can you tell me otherwise? Can you suggest any other method to spoof browser time settings that works with Selenium? I am open for Windows/Linux solutions. Yet this way has to work with webdriver automation. -Olivier (Indeed a great blend of people here at stackexchange.)



  • The browser date/time functions are all JavaScript. You should be able to use Sinon.JS or TimeShift.JS to mock the date/time. Inject/Add the mocking framework during tests runs Mock the Date object with the JavaScript Executor Set the timezone Run tests Now all calls to the internal Date object will return the shifted time. For examples see this post with TimeShift.JS and something like this is also described in this blog post, although it uses ruby TimeCop for time sync.



Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2