@@ -298,6 +298,15 @@ def clickAndWait(self, uiObject2, eventCondition, timeout):
298298 params = {'eventCondition' : eventCondition , 'timeout' : timeout }
299299 return self .__httpCommand ('/UiObject2/%d/clickAndWait' % (uiObject2 .oid ), params )
300300
301+ def getText (self , uiObject2 ):
302+ response = self .__httpCommand ('/UiObject2/%d/getText' % (uiObject2 .oid ), None )
303+ r = json .loads (response )
304+ if r [u'status' ] == 'OK' :
305+ if DEBUG :
306+ print >> sys .stderr , "UiAutomatorHelper: getText: returning" , r [u'text' ]
307+ return r [u'text' ]
308+ raise RuntimeError ("Error: " + response )
309+
301310
302311 #
303312 # UiScrollable
@@ -342,8 +351,11 @@ def clickAndWait(self, eventCondition, timeout):
342351 def longClick (self ):
343352 self .uiAutomatorHelper .longClick (oid = self .oid )
344353
354+ def getText (self ):
355+ return self .uiAutomatorHelper .getText (uiObject2 = self )
356+
345357 def setText (self , text ):
346- self .uiAutomatorHelper .setText (uiObject = self , text = text )
358+ self .uiAutomatorHelper .setText (uiObject2 = self , text = text )
347359
348360
349361class UiScrollable :
@@ -360,5 +372,5 @@ def getChildByDescription(self, uiSelector, description, allowScrollSearch):
360372 return UiObject (self .uiAutomatorHelper , oid )
361373
362374 def getChildByText (self , uiSelector , text , allowScrollSearch ):
363- oid , response = self .uiAutomatorHelper .uiScrollable (str (self .oid ) + '/getChildByDescription ' , {'uiSelector' : uiSelector , 'text' : text , 'allowScrollSearch' : allowScrollSearch })
375+ oid , response = self .uiAutomatorHelper .uiScrollable (str (self .oid ) + '/getChildByText ' , {'uiSelector' : uiSelector , 'text' : text , 'allowScrollSearch' : allowScrollSearch })
364376 return UiObject (self .uiAutomatorHelper , oid )
0 commit comments