Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to increase the timeout in CasperJS

I am using waitFor(). The code as below:

casper.waitFor(function check() {     return this.evaluate(function() {         return this.evaluate(someFunction, 'variable 1','variable 2','variable 3') === 'yes';     }); }, function then() {     console.log('Done'); }); 

Am getting this as console output

Wait timeout of 5000ms expired, exiting. 

How can I increase the timeout?

EDIT: I have changed the code to

 casper.waitFor(function check() {         return this.evaluate(function() {             return this.evaluate(someFunction, 'variable 1','variable 2','variable 3') === 'yes';         });     }, function then() {         console.log('Done');     },10000); 

It's giving me the following error:

CasperError: Invalid timeout function, exiting.     C:/filename:1720 in _check 
like image 919
user2129794 Avatar asked Aug 13 '13 08:08

user2129794


2 Answers

Use that to increase the timeout of every wait() functions : casper.options.waitTimeout = 20000; (20sec)

like image 95
Fanch Avatar answered Sep 19 '22 22:09

Fanch


As said here,

The signature is

waitFor(Function testFx[, Function then, Function onTimeout, Number timeout]) 

So, there is an additionnal argument to specify the timeout.

casper.waitFor(function check() {     //...     }); }, function then() {      //... }, function timeout() {  //... }, TIMEOUT_IN_MS); 
like image 28
Cybermaxs Avatar answered Sep 19 '22 22:09

Cybermaxs