简体   繁体   中英

casper.js exit instance onStepTimeout

Hi i have the following code in 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();
});

Now in this code i have stepTimeout to 2400ms , but when this timeout is reached the script echo'es timeout: step + step name but doesn't moves to next instance or step... What i want is that when that stepTimeout is reached that instance should instantly exit() and move to the next thenOpen() instance... Any way around for this?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM