Search code examples
angularjsgoogle-chromeselenium-webdriverprotractorend-to-end

How to change the date and time of my computer device, using protractor


I need to test whether announcements are expired or not after 6 months. Currently I am successfully testing that announcement is correct or not.

After 6 months it must be removed from a particular tab. The problem is: How can I simulate a system time 6 months in the future with protractor?


Solution

  • Think about it differently.

    Mock the HTTP response that your app sends containing announcements and set the desired date using protractor-http-mock library. In other words, let the frontend think there is an expired announcement.


    Alternative options would include mocking the time with the help of Sinon.js or TimeShift.js, but, personally, I think that involving these tools would be an overcomplication. Anyway, see: