Bug 1387644 - Return NoSuchElementError when element is not found r?ato draft
authorDavid Burns <dburns@mozilla.com>
Sat, 05 Aug 2017 00:50:46 +0100
changeset 641210 8bd423761104595985dc4efaf05bf0b7b0e53a32
parent 619251 71df96e65afad583532ff8351b1c1022324507c6
child 724750 fddd9979028855e7c83093c56225991d89618e0b
push id72475
push userbmo:dburns@mozilla.com
push dateSun, 06 Aug 2017 09:11:41 +0000
reviewersato
bugs1387644
milestone56.0a1
Bug 1387644 - Return NoSuchElementError when element is not found r?ato MozReview-Commit-ID: LDHiyce09GR
testing/marionette/element.js
testing/marionette/harness/marionette_harness/tests/unit/test_screenshot.py
--- 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()