1818@author: Diego Torres Milano
1919'''
2020
21- __version__ = '15.1.2 '
21+ __version__ = '15.1.3 '
2222
2323import json
2424import os
@@ -305,8 +305,9 @@ def waitForIdle(self, timeout):
305305 # UiObject
306306 #
307307 def setText (self , uiObject , text ):
308+ # NOTICE: uiObject can receive UiObject or UiObject2
308309 params = {'text' : text }
309- return self .__httpCommand ('/UiObject/0x%x/setText' % ( uiObject .oid ) , params )
310+ return self .__httpCommand ('/UiObject/0x%x/setText' % uiObject .oid , params )
310311
311312 #
312313 # UiObject2
@@ -315,11 +316,11 @@ def clickAndWait(self, uiObject2, eventCondition, timeout):
315316 params = {'eventCondition' : eventCondition , 'timeout' : timeout }
316317 return self .__httpCommand ('/UiObject2/%d/clickAndWait' % (uiObject2 .oid ), params )
317318
318- def getText (self , uiObject = None , uiObject2 = None ):
319+ def getText (self , uiObject = None ):
320+ # NOTICE: uiObject can receive UiObject or UiObject2
321+ element = uiObject .__class__ .__name__
319322 if uiObject :
320- path = '/UiObject/%d/getText' % (uiObject .oid )
321- elif uiObject2 :
322- path = '/UiObject2/%d/getText' % (uiObject2 .oid )
323+ path = '/%s/%d/getText' % (element , uiObject .oid )
323324 else :
324325 raise ValueError ("No uiObject or uiObject2 specified" )
325326 response = self .__httpCommand (path , None )
@@ -412,10 +413,14 @@ def longClick(self):
412413 self .uiAutomatorHelper .longClick (oid = self .oid )
413414
414415 def getText (self ):
415- return self .uiAutomatorHelper .getText (uiObject2 = self )
416+ # NOTICE: even if this is an uiObject2 we are invoking the only "getText" method in UiAutomatorHelper
417+ # passing the uiObject2 as uiObject
418+ return self .uiAutomatorHelper .getText (uiObject = self )
416419
417420 def setText (self , text ):
418- self .uiAutomatorHelper .setText (uiObject2 = self , text = text )
421+ # NOTICE: even if this is an uiObject2 we are invoking the only "setText" method in UiAutomatorHelper
422+ # passing the uiObject2 as uiObject
423+ self .uiAutomatorHelper .setText (uiObject = self , text = text )
419424
420425
421426class UiScrollable :
0 commit comments