missx
Newbie
- Jun 13, 2015
- 1
- 0
Hi, I'm trying to fake the system time when using Chromedriver, tried everything, nothing works and I'm out of ideas. I'm using Chromedriver as a lib in java and checking if the system time is faked at whoer.net. I want whoer to show the system time equal to local time (which I can know by my proxie's ip). Now whoer keeps showing my Windows time at the "System time" field, no matter what I do.
Wht did I try:
1. Adding some chrome options
2. Setting system property
3. Injecting Javascript
And another variant of javascript
4. Setting Windows system time via cmd:
Only variant #4 worked but it's useless for me since I want to make a multithreaded bot with many instances of Chromedriver each one with different system time.
Don't understand at all why javascript injection doesn't work.
Please help. How to fake the system time?
Wht did I try:
1. Adding some chrome options
Code:
chromeOptions.put("args", Arrays.asList("--lang=en", "--disable-web-security", "--disable-local-storage",
"--disable-system-timezone-automatic-detection", "--disable-webgl", "--dns-prefetch-disable",
"--disable-plugins-discovery", "--local-timezone", "--disable-timezone-tracking-option",
"--enable-virtualized-time"));
2. Setting system property
Code:
System.setProperty("user.timezone", "GMT");
TimeZone.setDefault(null);
3. Injecting Javascript
Code:
((JavascriptExecutor) driver).executeScript("var d = new Date(2012, 0, 20); Date = undefined; Date = function(){return d;}");
And another variant of javascript
Code:
((JavascriptExecutor) driver).executeScript("var dateYouWant = 1363798981693; Date.prototype.getTime = function() { return dateYouWant; }; console.log( (new Date).getTime() );");
4. Setting Windows system time via cmd:
Code:
Runtime.getRuntime().exec("cmd /C time " + "16:56:10");
Only variant #4 worked but it's useless for me since I want to make a multithreaded bot with many instances of Chromedriver each one with different system time.
Don't understand at all why javascript injection doesn't work.
Please help. How to fake the system time?