File tree Expand file tree Collapse file tree 4 files changed +19
-1
lines changed Expand file tree Collapse file tree 4 files changed +19
-1
lines changed Original file line number Diff line number Diff line change @@ -28,6 +28,7 @@ class MobileCommand(object):
28
28
DEACTIVATE_IME_ENGINE = 'deactivateIMEEngine'
29
29
GET_ACTIVE_IME_ENGINE = 'getActiveEngine'
30
30
TOGGLE_LOCATION_SERVICES = 'toggleLocationServices'
31
+ LOCATION_IN_VIEW = 'locationInView'
31
32
32
33
# Appium Commands
33
34
GET_APP_STRINGS = 'getAppStrings'
Original file line number Diff line number Diff line change @@ -782,7 +782,7 @@ def _addCommands(self):
782
782
self .command_executor ._commands [Command .GET_ACTIVE_IME_ENGINE ] = \
783
783
('GET' , '/session/$sessionId/ime/active_engine' )
784
784
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' )
786
786
self .command_executor ._commands [Command .GET_SETTINGS ] = \
787
787
('GET' , '/session/$sessionId/appium/settings' )
788
788
self .command_executor ._commands [Command .UPDATE_SETTINGS ] = \
@@ -791,6 +791,8 @@ def _addCommands(self):
791
791
('POST' , '/session/$sessionId/appium/device/toggle_location_services' )
792
792
self .command_executor ._commands [Command .SET_LOCATION ] = \
793
793
('POST' , '/session/$sessionId/location' )
794
+ self .command_executor ._commands [Command .LOCATION_IN_VIEW ] = \
795
+ ('GET' , '/session/$sessionId/element/$id/location_in_view' )
794
796
795
797
796
798
# monkeypatched method for WebElement
Original file line number Diff line number Diff line change @@ -103,3 +103,12 @@ def set_text(self, keys=''):
103
103
}
104
104
self ._execute (Command .REPLACE_KEYS , data )
105
105
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):
220
220
def test_toggle_location_services (self ):
221
221
self .driver .toggle_location_services ()
222
222
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
+
223
229
224
230
if __name__ == "__main__" :
225
231
suite = unittest .TestLoader ().loadTestsFromTestCase (AppiumTests )
You can’t perform that action at this time.
0 commit comments