I can't figure out how to set a timezone when using Chromedriver. Is there some ChromeOptions argument or something?
The issue is that when I go to some sites (for example, https://whoer.net), it shows the system time that is equal to the time set on Windows. And I want to be able to change the Chromedriver's timezone somehow to perform timezone dependent testing.
I tried to set some chrome options:
Map<String, Object> chromeOptions = new HashMap<String, Object>();
chromeOptions.put("args", Arrays.asList("--disable-system-timezone-automatic-detection", "--local-timezone"));
DesiredCapabilities capabilities = DesiredCapabilities.chrome();
capabilities.setCapability(ChromeOptions.CAPABILITY, chromeOptions);
It doesn't work.
Tried to do some weird thing using Javascript:
((JavascriptExecutor) driver).executeScript("Date.prototype.getTime = function() { return 1 };");
It didn't help either.
EDIT:
Found this https://sqa.stackexchange.com/questions/8838/faking-system-time-date-with-selenium-webdriver
Tried to execute javascript on page with the code copied from TimeShift.js like this:
((JavascriptExecutor) driver).executeScript("/*code from TimeShift.js here*/ TimeShift.setTimezoneOffset(-60);");
System time at https://whoer.net didn't change. What am I doing wrong?