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
This commit is contained in:
Andreas Tolfsen 2015-04-17 17:02:14 +01:00
Родитель 7a242bbc5d
Коммит 06c35da2a3
1 изменённых файлов: 13 добавлений и 12 удалений

Просмотреть файл

@ -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):