Cómo aumentar el tiempo de espera en CasperJS


Estoy usando waitFor(). El código de la siguiente manera:

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

Estoy obteniendo esto como salida de consola

Wait timeout of 5000ms expired, exiting.

¿Cómo puedo aumentar el tiempo de espera?

EDITAR: He cambiado el código a

 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);

Me está dando el siguiente error:

CasperError: Invalid timeout function, exiting.
    C:/filename:1720 in _check
Author: warvariuc, 2013-08-13

3 answers

Como se dijo aquí ,

La firma es

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

Por lo tanto, hay un argumento adicional para especificar el tiempo de espera.

casper.waitFor(function check() {
    //...
    });
}, function then() {
     //...
}, function timeout() { 
//...
}, TIMEOUT_IN_MS);
 27
Author: Cybermaxs,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2013-08-13 18:22:22

Use esto para aumentar el tiempo de espera de cada función wait (): casper.options.waitTimeout = 20000; (20seg)

 56
Author: Fanch,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2015-09-14 11:37:25

Si desea aumentar el tiempo de espera mientras deja el mensaje de error predeterminado, pase null como tercer argumento y el número de milisegundos a esperar como cuarto argumento:

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);
 1
Author: warvariuc,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2015-04-16 13:28:50