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
Use that to increase the timeout of every wait() functions : casper.options.waitTimeout = 20000;
(20sec)
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);
If you want to increase timeout while leaving the default error message, pass null
as the third argument and number of milliseconds to wait as the fourth argument:
casper.waitFor(function check() {
return this.evaluate(function() {
return this.evaluate(someFunction, 'variable 1','variable 2','variable 3') === 'yes';
});
}, function then() {
console.log('Done');
}, null, 10000);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.