fixed erroneous error handling in Casper.capture()
Showing
2 changed files
with
3 additions
and
4 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; | ... | ... |
-
Please register or sign in to post a comment