0

Is there any way to generate "Random date value" to test a "date picker" in the "angualr 4 web application" using "Protractor".

Aswini
  • 3
  • 4
  • Possible duplicate of [Elegant method to generate array of random dates within two dates](https://stackoverflow.com/questions/9035627/elegant-method-to-generate-array-of-random-dates-within-two-dates) – Gunderson Oct 30 '17 at 17:25
  • 1
    Protractor is just a node app. There are plenty of ways to generate random dates in node/javascript, see [this question](https://stackoverflow.com/questions/9035627/elegant-method-to-generate-array-of-random-dates-within-two-dates) – Gunderson Oct 30 '17 at 17:29
  • +1 for the point that protractor is an NodeJs/ JavaScript app.I see lot of places people label plain JavaScript/NodeJs problems as Protractor issue. – Vishal Aggarwal Nov 03 '17 at 11:35

1 Answers1

2

You need to write your own function which will return random date.

 findRandomDate(start, end) {
        return new Date(start.getTime() + Math.random() * (end.getTime() - start.getTime()));
    }

    this.findRandomDate(new Date(2012, 0, 1), new Date());
Eric Aya
  • 69,473
  • 35
  • 181
  • 253
dats
  • 210
  • 2
  • 7