mardi 20 janvier 2015

CasperJS WaitFor not waiting for the condition to finish

I'm relatively new to casperJS.I have script where i want to perform operation in page B(i.e Verify the confirmation mail for user),then proceed with execution in page A.code snippet is as follows



casper.waitFor(function(){
return this.run(function(){
return verifyEmail(user_details['email']);
});
},function then(){
this.wait(60000, function() {
this.reload(function(){
this.echo("Refresh");
this.capture('after-reload-a.png');
});
});
});


and the function verifyEmail is defined as follows:



function verifyEmail(email){
return casper.open('someURL').then(function(response){
//extract URL from response
this.echo("URL"+url);
casper.start().thenOpen(url, function() {
this.waitForText('someText',function(){
this.capture("final.jpg");
});
});
return url;
});
};


During the execution,Casper never executes the function verifyEmail(URL is never printed) and proceeds with then() function.What am i missing here?


Aucun commentaire:

Enregistrer un commentaire