@@ -906,7 +906,11 @@ def __init__(self, device, serialno, adb=None, autodump=True, localport=VIEW_SER
906906 self .useUiAutomator = (self .build [VERSION_SDK_PROPERTY ] >= 16 ) # jelly bean 4.1 & 4.2
907907 ''' If UIAutomator is supported by the device it will be used '''
908908
909- if not self .useUiAutomator :
909+ if self .useUiAutomator :
910+ self .textProperty = TEXT_PROPERTY_UI_AUTOMATOR
911+ else :
912+ # FIXME: not true for API <= 10
913+ self .textProperty = TEXT_PROPERTY
910914 if startviewserver :
911915 if not self .serviceResponse (device .shell ('service call window 3' )):
912916 try :
@@ -1595,7 +1599,7 @@ def findViewWithAttributeThatMatches(self, attr, regex, root="ROOT"):
15951599
15961600 def findViewWithText (self , text , root = "ROOT" ):
15971601 if type (text ).__name__ == 'PatternObject' :
1598- return self .findViewWithAttributeThatMatches (TEXT_PROPERTY , text , root )
1602+ return self .findViewWithAttributeThatMatches (self . textProperty , text , root )
15991603 #l = self.findViewWithAttributeThatMatches(TEXT_PROPERTY, text)
16001604 #ll = len(l)
16011605 #if ll == 0:
@@ -1606,7 +1610,7 @@ def findViewWithText(self, text, root="ROOT"):
16061610 # print >>sys.stderr, "WARNING: findViewWithAttributeThatMatches invoked by findViewWithText returns %d items." % ll
16071611 # return l
16081612 else :
1609- return self .findViewWithAttribute (TEXT_PROPERTY , text , root )
1613+ return self .findViewWithAttribute (self . textProperty , text , root )
16101614
16111615 def findViewWithTextOrRaise (self , text , root = "ROOT" ):
16121616 '''
0 commit comments