added Casper.options.onRunComplete() handler
Showing
1 changed file
with
5 additions
and
3 deletions
... | @@ -96,6 +96,9 @@ var Casper = function Casper(options) { | ... | @@ -96,6 +96,9 @@ var Casper = function Casper(options) { |
96 | onPageInitialized: null, | 96 | onPageInitialized: null, |
97 | onResourceReceived: null, | 97 | onResourceReceived: null, |
98 | onResourceRequested: null, | 98 | onResourceRequested: null, |
99 | onRunComplete: function _onRunComplete() { | ||
100 | this.exit(); | ||
101 | }, | ||
99 | onStepComplete: null, | 102 | onStepComplete: null, |
100 | onStepTimeout: function _onStepTimeout(timeout, stepNum) { | 103 | onStepTimeout: function _onStepTimeout(timeout, stepNum) { |
101 | this.die("Maximum step execution timeout exceeded for step " + stepNum); | 104 | this.die("Maximum step execution timeout exceeded for step " + stepNum); |
... | @@ -343,9 +346,8 @@ Casper.prototype.checkStep = function checkStep(self, onComplete) { | ... | @@ -343,9 +346,8 @@ Casper.prototype.checkStep = function checkStep(self, onComplete) { |
343 | self.emit('run.complete'); | 346 | self.emit('run.complete'); |
344 | if (utils.isFunction(onComplete)) { | 347 | if (utils.isFunction(onComplete)) { |
345 | onComplete.call(self, self); | 348 | onComplete.call(self, self); |
346 | } else { | 349 | } else if (utils.isFunction(self.options.onRunComplete)) { |
347 | // default behavior is to exit | 350 | self.options.onRunComplete.call(self, self); |
348 | self.exit(); | ||
349 | } | 351 | } |
350 | } | 352 | } |
351 | }; | 353 | }; | ... | ... |
-
Please register or sign in to post a comment