嗨,我在 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 + step name but doesn't move to next instance or step ...我想要的是当达到那个 stepTimeout该实例应立即 exit() 并移至下一个 thenOpen() 实例...有什么办法吗?