File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -28,6 +28,7 @@ class MobileCommand(object):
2828 DEACTIVATE_IME_ENGINE = 'deactivateIMEEngine'
2929 GET_ACTIVE_IME_ENGINE = 'getActiveEngine'
3030 TOGGLE_LOCATION_SERVICES = 'toggleLocationServices'
31+ LOCATION_IN_VIEW = 'locationInView'
3132
3233 # Appium Commands
3334 GET_APP_STRINGS = 'getAppStrings'
Original file line number Diff line number Diff line change @@ -782,7 +782,7 @@ def _addCommands(self):
782782 self .command_executor ._commands [Command .GET_ACTIVE_IME_ENGINE ] = \
783783 ('GET' , '/session/$sessionId/ime/active_engine' )
784784 self .command_executor ._commands [Command .REPLACE_KEYS ] = \
785- ('POST' , '/session/$sessionId/appium/element/$elementId /replace_value' )
785+ ('POST' , '/session/$sessionId/appium/element/$id /replace_value' )
786786 self .command_executor ._commands [Command .GET_SETTINGS ] = \
787787 ('GET' , '/session/$sessionId/appium/settings' )
788788 self .command_executor ._commands [Command .UPDATE_SETTINGS ] = \
@@ -791,6 +791,8 @@ def _addCommands(self):
791791 ('POST' , '/session/$sessionId/appium/device/toggle_location_services' )
792792 self .command_executor ._commands [Command .SET_LOCATION ] = \
793793 ('POST' , '/session/$sessionId/location' )
794+ self .command_executor ._commands [Command .LOCATION_IN_VIEW ] = \
795+ ('GET' , '/session/$sessionId/element/$id/location_in_view' )
794796
795797
796798# monkeypatched method for WebElement
Original file line number Diff line number Diff line change @@ -103,3 +103,12 @@ def set_text(self, keys=''):
103103 }
104104 self ._execute (Command .REPLACE_KEYS , data )
105105 return self
106+
107+ @property
108+ def location_in_view (self ):
109+ """Gets the location of an element relative to the view.
110+
111+ :Usage:
112+ location = element.location_in_view
113+ """
114+ return self ._execute (Command .LOCATION_IN_VIEW )['value' ]
Original file line number Diff line number Diff line change @@ -220,6 +220,12 @@ def test_update_settings(self):
220220 def test_toggle_location_services (self ):
221221 self .driver .toggle_location_services ()
222222
223+ def test_element_location_in_view (self ):
224+ el = self .driver .find_element_by_name ('Content' )
225+ loc = el .location_in_view
226+ self .assertIsNotNone (loc ['x' ])
227+ self .assertIsNotNone (loc ['y' ])
228+
223229
224230if __name__ == "__main__" :
225231 suite = unittest .TestLoader ().loadTestsFromTestCase (AppiumTests )
You can’t perform that action at this time.
0 commit comments