Skip to content

Commit

Permalink
[Py] Update webelement to handle W3C commands for size/location and rect
Browse files Browse the repository at this point in the history
  • Loading branch information
AutomatedTester committed Jan 28, 2016
1 parent c489f7c commit cd218d0
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions py/selenium/webdriver/remote/webelement.py
Original file line number Diff line number Diff line change
Expand Up @@ -353,10 +353,13 @@ def location_once_scrolled_into_view(self):
@property
def size(self):
"""The size of the element."""
size = self._execute(Command.GET_ELEMENT_SIZE)['value']
new_size = {}
new_size["height"] = size["height"]
new_size["width"] = size["width"]
size = {}
if self._w3c:
size = self._execute(Command.GET_ELEMENT_RECT)
else:
size = self._execute(Command.GET_ELEMENT_SIZE)['value']
new_size = {"height": size["height"],
"width": size["width"]}
return new_size

def value_of_css_property(self, property_name):
Expand All @@ -367,15 +370,21 @@ def value_of_css_property(self, property_name):
@property
def location(self):
"""The location of the element in the renderable canvas."""
old_loc = self._execute(Command.GET_ELEMENT_LOCATION)['value']
if self._w3c:
old_loc = self._execute(Command.GET_ELEMENT_RECT)
else:
old_loc = self._execute(Command.GET_ELEMENT_LOCATION)['value']
new_loc = {"x": old_loc['x'],
"y": old_loc['y']}
return new_loc

@property
def rect(self):
"""A dictionary with the size and location of the element."""
return self._execute(Command.GET_ELEMENT_RECT)['value']
if self._w3c:
return self._execute(Command.GET_ELEMENT_RECT)
else:
return self._execute(Command.GET_ELEMENT_RECT)['value']

@property
def screenshot_as_base64(self):
Expand Down

0 comments on commit cd218d0

Please sign in to comment.