How to run a loop with a specific interval in casperjs? <p>I want to automate clicking a button with <code>id='vote'</code> 3 times with an interval of say 5 seconds with <strong>casperjs</strong>, for that I have written the code below</p> <pre><code> var casper = require('casper').create(); casper.start('http://www.mysite.com/mypage'); casper.repeat(3, function() { this.click('#vote'); }); casper.then(function() { console.log('clicked vote ,and voted successfully , and curernt url is ' + this.getCurrentUrl()); }); casper.run(); </code></pre> <p>But this only working once, what I want to do is to repeat the loop 3 times with a specific interval, since this is a JavaScript ajax post on clicking the vote button and it updates the database, is it doing all 3 clicks at once? What do I have to do to avoid that, and update the database 3 times?</p>