1818@author: Diego Torres Milano
1919'''
2020
21- __version__ = '12.1.1 '
21+ __version__ = '12.1.2 '
2222
2323import os
2424import subprocess
@@ -303,7 +303,24 @@ def clickAndWait(self, uiObject2, eventCondition, timeout):
303303 # UiScrollable
304304 #
305305 def uiScrollable (self , path , params ):
306- return self .__httpCommand ('/UiScrollable/' + path , params )
306+ response = self .__httpCommand ('/UiScrollable/' + path , params )
307+ if DEBUG :
308+ print >> sys .stderr , "UiAutomatorHelper: uiScrollable: response=" , response
309+ r = json .loads (response )
310+ if r [u'status' ] == 'OK' :
311+ if DEBUG :
312+ print >> sys .stderr , "UiAutomatorHelper: uiScrollable: returning" , int (r [u'oid' ])
313+ return int (r [u'oid' ]), r
314+ raise RuntimeError ("Error: " + response )
315+
316+
317+ class UiObject :
318+ def __init__ (self , uiAutomatorHelper , oid ):
319+ self .uiAutomatorHelper = uiAutomatorHelper
320+ self .oid = oid
321+
322+ def click (self ):
323+ self .uiAutomatorHelper .click (oid = self .oid )
307324
308325
309326class UiObject2 :
@@ -326,10 +343,18 @@ def setText(self, text):
326343
327344
328345class UiScrollable :
329- def __init__ (self , uiAutomatorHelper , selector ):
346+ def __init__ (self , uiAutomatorHelper , uiSelector ):
330347 self .uiAutomatorHelper = uiAutomatorHelper
331- self .selector = selector
348+ self .uiSelector = uiSelector
349+ self .oid , self .response = self .__createUiScrollable ()
350+
351+ def __createUiScrollable (self ):
352+ return self .uiAutomatorHelper .uiScrollable ('new' , {'uiSelector' : self .uiSelector })
332353
333- def createUiScrollable (self ):
334- return self .uiAutomatorHelper .uiScrollable ('new' , {'uiSelector' : self .selector })
354+ def getChildByDescription (self , uiSelector , description , allowScrollSearch ):
355+ oid , response = self .uiAutomatorHelper .uiScrollable (str (self .oid ) + '/getChildByDescription' , {'uiSelector' : uiSelector , 'contentDescription' : description , 'allowScrollSearch' : allowScrollSearch })
356+ return UiObject (self .uiAutomatorHelper , oid )
335357
358+ def getChildByText (self , uiSelector , text , allowScrollSearch ):
359+ oid , response = self .uiAutomatorHelper .uiScrollable (str (self .oid ) + '/getChildByDescription' , {'uiSelector' : uiSelector , 'text' : text , 'allowScrollSearch' : allowScrollSearch })
360+ return UiObject (self .uiAutomatorHelper , oid )
0 commit comments