0

i have written a script using Selenium Webdriver. Just wanted to know if there is a way to make this script run every 15mins?

Like if i schedule it for 1 hour, Scripts should run every 15 mins and at the end of 1 hour it should post the results to an excel sheet. Can someone pls help me on this?

3 Answers3

1

As you are a beginner, so I am trying to provide you a very easy solution, might be not very much efficient.

static Timer timer = new Timer();
timer.scheduleAtFixedRate(new TimerTask() {
              @Override
              public void run() {
                // Your database code here
                  if(i==4){
                      timer.cancel();
                      timer.purge();
                  }
                  try {
                    execute();
                } catch (InterruptedException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
                  i++;

              }
            }, 0, 1*1000);

In Code, 1*1000 denotes like, after how many seconds , you want to execute your code. execute() -- will have your code to be run i :- number of times, you want to repeat your test in your case i=4 timeRate should be :- 15*60*1000

Anil Chandna
  • 180
  • 1
  • 9
0

Crontab is the best thing to do this job. Write a selenium script and run for every 15 min using crontab. Refer this link to run it for every 15 min.

How would I get a cron job to run every 30 minutes?

Community
  • 1
  • 1
Hideandseek
  • 271
  • 1
  • 4
  • 17
0

Jenkins or Hudson would be the ideal candidates to host this.

ReneS
  • 3,535
  • 2
  • 26
  • 35