i was wondering how can I wait two times 5 seconds and do different things in each wait with phantomjs. Here's the code:
var page = require('webpage').create();
page.open("http://www.google.com/", function(status){
var currentdate = new Date();
console.log("\n\n" + currentdate.getHours() + ":" + currentdate.getMinutes() + ":" + currentdate.getSeconds() + "\n\n");
setTimeout(function(){
var currentdate1 = new Date();
console.log("\n\n" + currentdate1.getHours() + ":" + currentdate1.getMinutes() + ":" + currentdate1.getSeconds() + "\n\n");
return "hahaha";
}, 5000);
setTimeout(function(){
var currentdate2 = new Date();
console.log("\n\n" + currentdate2.getHours() + ":" + currentdate2.getMinutes() + ":" + currentdate2.getSeconds() + "\n\n");
phantom.exit();
return "hahaha";
}, 5000);
});
Why is phantomjs the second setTimeout function is not working properly?? How can I solve this problem? The output i want to achieve is this:
16:13:10
16:13:15
16:13:20
And not this (as now it does):
16:13:10
16:13:15
16:13:15
Sorry for my bad english. Thanks