Commit de27282e de27282e156c56d06cb369ddb22865c41257236e by Nicolas Perriault

Casper.mouseEvent() now triggers an error on failure

1 parent 0a603803
......@@ -49,6 +49,8 @@ The whole [CapserJS test suite](https://github.com/n1k0/casperjs/tree/master/tes
Native mouse events from PhantomJS bring a far more accurate behavior.
Also, `Casper.mouseEvent()` will now directly trigger an error on failure instead of just logging an `error` event.
### Bugfixes & enhancements
- fixed [#300](https://github.com/n1k0/casperjs/issues/300) - Ensure that `findOne()` and `findAll()` observe the scope for XPath expressions, not just when passed CSS selectors
......
......@@ -1113,9 +1113,9 @@ Casper.prototype.log = function log(message, level, space) {
Casper.prototype.mouseEvent = function mouseEvent(type, selector) {
"use strict";
this.checkStarted();
this.log("Mouse event '" + type + "' on selector: " + selector, "debug");
this.log(f("Mouse event '%s' on selector: %s", type, selector), "debug");
if (!this.exists(selector)) {
throw new CasperError(f("Cannot dispatch %s event on nonexistent selector: %s", type, selector));
throw new CasperError(f("Cannot dispatch '%s' event on nonexistent selector: %s", type, selector));
}
// PhantomJS doesn't provide native events for mouseover & mouseout
if (type === "mouseover" || type === "mouseout") {
......@@ -1123,12 +1123,7 @@ Casper.prototype.mouseEvent = function mouseEvent(type, selector) {
return window.__utils__.mouseEvent(type, selector);
}, type, selector);
}
try {
this.mouse.processEvent(type, selector);
} catch (e) {
this.log(f("Couldn't emulate '%s' event on %s: %s", type, selector, e), "error");
return false;
}
return true;
};
......
......@@ -72,8 +72,7 @@ var Mouse = function Mouse(casper) {
throw new CasperError('Mouse.processEvent(): Too few arguments');
case 1:
// selector
var selector = args[0];
casper.page.sendEvent.apply(casper.page, [type].concat(computeCenter(selector)));
casper.page.sendEvent.apply(casper.page, [type].concat(computeCenter(args[0])));
break;
case 2:
// coordinates
......