[英]casper.js exit instance onStepTimeout
嗨,我在casper.js中有以下代码
var casper = require('casper').create({
pageSettings: {loadImages : true,loadPlugins : false},
logLevel :"debug" ,
verbose : true,
onTimeout : function(){ //what to do if timeout reaches?
this.echo('Failed to load resource.').exit();
},
onStepTimeout: function(){ //what to do if specific step timeout reaches.
this.echo('timeout: step '+ this.requestUrl);
}
});
//our userAgent
casper.userAgent('Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:25.0) Gecko/20100101 Firefox/25.0');
casper.echo("Will google.com load in less than 2000 ms?");
casper.options.timeout = 2400100; //4 Minutes for process to complete it self.
casper.options.stepTimeout = 24000; //24 seconds for each step to complete it self.
casper.start("http://www.google.com/", function() {
this.echo("Google done!");
this.clear();
});
casper.thenOpen("http://www.bing.com/", function() {
this.echo("Bing done!");
this.clear();
});
casper.run(function() {
this.echo('Finished everything!');
this.exit();
});
现在在这段代码中,我将stepTimeout设置为2400ms,但是当达到此超时时,脚本将回显超时:step +步骤名称,但不会移动到下一个实例或步骤...我想要的是,当达到stepTimeout时该实例应立即退出()并移至下一个thenOpen()实例...对此有何解决方法?
看看这个https://github.com/n1k0/casperjs/blob/master/samples/steptimeout.js#L17尝试使用test.fail和test.pass
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.