From 06c35da2a3ebac56390507b5b6e9b276e08f0789 Mon Sep 17 00:00:00 2001 From: Andreas Tolfsen Date: Fri, 17 Apr 2015 17:02:14 +0100 Subject: [PATCH] Bug 1154525: Make HTMLElement#location and #size use #rect internally getElementSize and getElementLocation are getting removed from the Marionette server (bug 1153911) and this is in preparation for that. Fortunately getElementRect is backwards compatible and we can extract the properties we need from that dictionary. r=chmanchester --HG-- extra : rebase_source : 8d4d8c005c90f335f4c241e677973807cfca0cb4 --- .../driver/marionette_driver/marionette.py | 25 ++++++++++--------- 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/testing/marionette/driver/marionette_driver/marionette.py b/testing/marionette/driver/marionette_driver/marionette.py index a7c59026cc37..302032158d2b 100644 --- a/testing/marionette/driver/marionette_driver/marionette.py +++ b/testing/marionette/driver/marionette_driver/marionette.py @@ -123,12 +123,11 @@ class HTMLElement(object): @property def size(self): - ''' - A dictionary with the size of the element. - ''' + """A dictionary with the size of the element.""" warnings.warn("The size property has been deprecated and will be removed in a future version. \ Please use HTMLElement#rect", DeprecationWarning) - return self.marionette._send_message('getElementSize', 'value', id=self.id) + rect = self.rect + return {"width": rect["width"], "height": rect["height"]} @property def tag_name(self): @@ -150,18 +149,20 @@ class HTMLElement(object): """ warnings.warn("The location property has been deprecated and will be removed in a future version. \ Please use HTMLElement#rect", DeprecationWarning) - return self.marionette._send_message("getElementLocation", "value", id=self.id) + rect = self.rect + return {"x": rect["x"], "y": rect["y"]} @property def rect(self): + """Gets the element's bounding rectangle. + + This will return a dictionary with the following: + + * x and y represent the top left coordinates of the ``HTMLElement`` + relative to top left corner of the document. + * height and the width will contain the height and the width + of the DOMRect of the ``HTMLElement``. """ - this will return a dictionary with the following: - - * x and y represent the top left coordinates of the WebElement relative to top left corner of the document. - * height and the width will contain the height and the width of the DOMRect of the WebElement. - - """ - return self.marionette._send_message("getElementRect", "value", id=self.id) def value_of_css_property(self, property_name):