restablished js-emulated click simulation first, then native QtWebKit events as …
…a fallback; some real world testing have surprinsingly proven the former being often more efficient than the latter
Showing
2 changed files
with
16 additions
and
6 deletions
... | @@ -177,6 +177,7 @@ Casper.prototype.capture = function capture(targetFile, clipRect) { | ... | @@ -177,6 +177,7 @@ Casper.prototype.capture = function capture(targetFile, clipRect) { |
177 | if (!this.page.render(this.filter('capture.target_filename', targetFile) || targetFile)) { | 177 | if (!this.page.render(this.filter('capture.target_filename', targetFile) || targetFile)) { |
178 | this.log(f("Failed to save screenshot to %s; please check permissions", targetFile), "error"); | 178 | this.log(f("Failed to save screenshot to %s; please check permissions", targetFile), "error"); |
179 | } else { | 179 | } else { |
180 | this.log(f("Capture saved to %s", targetFile), "info"); | ||
180 | this.emit('capture.saved', targetFile); | 181 | this.emit('capture.saved', targetFile); |
181 | } | 182 | } |
182 | if (previousClipRect) { | 183 | if (previousClipRect) { |
... | @@ -242,11 +243,20 @@ Casper.prototype.click = function click(selector, fallbackToHref) { | ... | @@ -242,11 +243,20 @@ Casper.prototype.click = function click(selector, fallbackToHref) { |
242 | if (arguments.length > 1) { | 243 | if (arguments.length > 1) { |
243 | this.emit("deprecated", "The click() method does not process the fallbackToHref argument since 0.6"); | 244 | this.emit("deprecated", "The click() method does not process the fallbackToHref argument since 0.6"); |
244 | } | 245 | } |
245 | try { | 246 | if (!this.exists(selector)) { |
246 | this.mouse.click(selector); | 247 | throw new CasperError("Cannot click on unexistent selector: " + selector); |
247 | } catch (e) { | 248 | } |
248 | this.log(f("Error while trying to click on selector %s: %s", selector, e)); | 249 | var clicked = this.evaluate(function(selector) { |
249 | return false; | 250 | __utils__.click(selector); |
251 | }, { selector: selector }); | ||
252 | if (!clicked) { | ||
253 | // fallback onto native QtWebKit mouse events | ||
254 | try { | ||
255 | this.mouse.click(selector); | ||
256 | } catch (e) { | ||
257 | this.log(f("Error while trying to click on selector %s: %s", selector, e)); | ||
258 | return false; | ||
259 | } | ||
250 | } | 260 | } |
251 | return true; | 261 | return true; |
252 | }; | 262 | }; | ... | ... |
-
Please register or sign in to post a comment