How to increase the timeout in CasperJS

user2129794 picture user2129794 · Aug 13, 2013 · Viewed 26.1k times · Source

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

Answer

Fanch picture Fanch · May 20, 2014

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