fixed erroneous error handling in Casper.capture()
Showing
2 changed files
with
4 additions
and
5 deletions
... | @@ -143,6 +143,7 @@ | ... | @@ -143,6 +143,7 @@ |
143 | */ | 143 | */ |
144 | capture: function(targetFile, clipRect) { | 144 | capture: function(targetFile, clipRect) { |
145 | var previousClipRect; | 145 | var previousClipRect; |
146 | targetFile = require('fs').absolute(targetFile); | ||
146 | if (clipRect) { | 147 | if (clipRect) { |
147 | if (!isType(clipRect, "object")) { | 148 | if (!isType(clipRect, "object")) { |
148 | throw new Error("clipRect must be an Object instance."); | 149 | throw new Error("clipRect must be an Object instance."); |
... | @@ -153,10 +154,8 @@ | ... | @@ -153,10 +154,8 @@ |
153 | } else { | 154 | } else { |
154 | this.log('Capturing page to ' + targetFile, "debug"); | 155 | this.log('Capturing page to ' + targetFile, "debug"); |
155 | } | 156 | } |
156 | try { | 157 | if (!this.page.render(targetFile)) { |
157 | this.page.render(targetFile); | 158 | this.log('Failed to save screenshot to ' + targetFile + '; please check permissions', "error"); |
158 | } catch (e) { | ||
159 | this.log('Failed to capture screenshot as ' + targetFile + ': ' + e, "error"); | ||
160 | } | 159 | } |
161 | if (previousClipRect) { | 160 | if (previousClipRect) { |
162 | this.page.clipRect = previousClipRect; | 161 | this.page.clipRect = previousClipRect; | ... | ... |
... | @@ -16,4 +16,4 @@ casper.start('https://twitter.com/#!/twilio', function(self) { | ... | @@ -16,4 +16,4 @@ casper.start('https://twitter.com/#!/twilio', function(self) { |
16 | 16 | ||
17 | casper.run(function(self) { | 17 | casper.run(function(self) { |
18 | self.exit(); | 18 | self.exit(); |
19 | }); | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
19 | }); | ... | ... |
-
Please register or sign in to post a comment