Bug 1387644 - Return NoSuchElementError when element is not found r?ato
MozReview-Commit-ID: LDHiyce09GR
--- a/testing/marionette/element.js
+++ b/testing/marionette/element.js
@@ -156,26 +156,27 @@ element.Store = class {
* @param {string} uuid
* Web element reference, or UUID.
* @param {(nsIDOMWindow|ShadowRoot)} container
* Window and an optional shadow root that contains the element.
*
* @returns {nsIDOMElement}
* Element associated with reference.
*
- * @throws {JavaScriptError}
+ * @throws {NoSuchElementError}
* If the provided reference is unknown.
* @throws {StaleElementReferenceError}
* If element has gone stale, indicating it is no longer attached to
* the DOM provided in the container.
*/
get(uuid, container) {
let el = this.els[uuid];
if (!el) {
- throw new JavaScriptError(`Element reference not seen before: ${uuid}`);
+ throw new NoSuchElementError(`Element reference not seen before: ` +
+ `${uuid}`);
}
try {
el = el.get();
} catch (e) {
el = null;
delete this.els[uuid];
}
--- a/testing/marionette/harness/marionette_harness/tests/unit/test_screenshot.py
+++ b/testing/marionette/harness/marionette_harness/tests/unit/test_screenshot.py
@@ -4,17 +4,17 @@
import base64
import hashlib
import imghdr
import struct
import urllib
from marionette_driver import By
-from marionette_driver.errors import JavascriptException, NoSuchWindowException
+from marionette_driver.errors import NoSuchElementException, NoSuchWindowException
from marionette_harness import (
MarionetteTestCase,
skip,
skip_if_mobile,
WindowManagerMixin,
)
@@ -270,22 +270,22 @@ class TestScreenCaptureChrome(WindowMana
self.marionette.switch_to_window(self.start_window)
def test_highlight_element_not_seen(self):
"""Check that for not found elements an exception is raised."""
with self.marionette.using_context('content'):
self.marionette.navigate(box)
content_element = self.marionette.find_element(By.ID, "green")
- self.assertRaisesRegexp(JavascriptException, "Element reference not seen before",
+ self.assertRaisesRegexp(NoSuchElementException, "Element reference not seen before",
self.marionette.screenshot, highlights=[content_element])
chrome_document_element = self.document_element
with self.marionette.using_context('content'):
- self.assertRaisesRegexp(JavascriptException, "Element reference not seen before",
+ self.assertRaisesRegexp(NoSuchElementException, "Element reference not seen before",
self.marionette.screenshot,
highlights=[chrome_document_element])
class TestScreenCaptureContent(WindowManagerMixin, ScreenCaptureTestCase):
def setUp(self):
super(TestScreenCaptureContent, self).setUp()