Bug 1385873 - Better error on wrong element to interaction.selectOption. r?automatedtester
Throw a better error message when the wrong element type is passed to
interaction.selectOption.
MozReview-Commit-ID: G1NIZ25umm2
--- a/testing/marionette/interaction.js
+++ b/testing/marionette/interaction.js
@@ -4,22 +4,23 @@
"use strict";
const {utils: Cu} = Components;
Cu.import("chrome://marionette/content/accessibility.js");
Cu.import("chrome://marionette/content/atom.js");
const {
+ ElementClickInterceptedError,
+ ElementNotInteractableError,
error,
InvalidArgument,
- ElementNotInteractableError,
- ElementClickInterceptedError,
+ InvalidArgumentError,
InvalidElementStateError,
- InvalidArgumentError,
+ pprint,
} = Cu.import("chrome://marionette/content/error.js", {});
Cu.import("chrome://marionette/content/element.js");
Cu.import("chrome://marionette/content/event.js");
Cu.importGlobalProperties(["File"]);
this.EXPORTED_SYMBOLS = ["interaction"];
@@ -279,17 +280,17 @@ function* seleniumClickElement(el, a11y)
* If unable to find <var>el</var>'s parent <tt><select></tt>
* element.
*/
interaction.selectOption = function(el) {
if (element.isXULElement(el)) {
throw new Error("XUL dropdowns not supported");
}
if (el.localName != "option") {
- throw new TypeError("Invalid elements");
+ throw new TypeError(pprint`Expected <option> element, got ${el}`);
}
let containerEl = element.getContainer(el);
event.mouseover(containerEl);
event.mousemove(containerEl);
event.mousedown(containerEl);
event.focus(containerEl);