I would like to skip a step in my Casperjs script when it takes too long to run that step.I used the solution suggested in (skip step) and I added stepTimeout and onStepTimeout handler. Here is the piece of code for doing that:
var casper = require("casper").create({
verbose: true,
stepTimeout: 10000,
pageSettings: {
loadImages: false,
loadPlugins: false,
ignoreSslErrors: true,
userAgent: 'Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/29.0.1547.2 Safari/537.36'
},
onStepTimeout: function() {
this.echo("Step " + this.step + "timed out ");
this.echo("Step .page" + this.step.page + "---- ");
this.clear();
this.page.stop();
}
});
The rest of the code simply opens a list of URLs. The problem is that for some cases such as opening this URL Google Desktop, when it takes longer than the specified timeout to open it, onStepTimeout event is fired but the value of this.page is undefined. So it results in crashing phantomjs(with segmentation fault).
I couldn't find any other solution to skip the current step and continue with the next step. Is there any other way to do ? any other suggestions?!