[英]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.