您好,我在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();
});现在在这段代码中,我将超时设置为2400ms,但当到达此超时时,脚本将回显stepTimeout : step + step name,但不会移动到下一个实例或步骤...我想要的是,当到达该stepTimeout时,该实例应该立即退出()并移动到下一个thenOpen()实例……有什么办法解决这个问题吗?
发布于 2013-11-21 18:31:45
看看这个,试着使用test.fail和test.pass
https://stackoverflow.com/questions/19386511
复制相似问题