Commit c0d6ee10 c0d6ee10d7943373a593e82bb7c6d926d9fd4fe6 by Nicolas Perriault

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
1 parent d2d13c69
1 Subproject commit f07aa7f99c84bb0de1b67e4e967586fa16979b86 1 Subproject commit 96895e7d4b64bf4d5c4cb9d62197b7c834a1e4ce
......
...@@ -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 };
......