File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 33from setuptools import setup , find_packages
44
55setup (name = 'androidviewclient' ,
6- version = '5.2 .0' ,
6+ version = '5.3 .0' ,
77 description = '''AndroidViewClient is a 100% pure python tool that
88 simplifies test script creation providing higher level operations and the ability of
99 obtaining the tree of Views present at any given moment on the device or emulator screen.
Original file line number Diff line number Diff line change 1818@author: Diego Torres Milano
1919'''
2020
21- __version__ = '5.2 .0'
21+ __version__ = '5.3 .0'
2222
2323import sys
2424import warnings
@@ -444,6 +444,11 @@ def getId(self):
444444 @see: L{getUniqueId()}
445445 '''
446446
447+ try :
448+ return self .map ['resource-id' ]
449+ except :
450+ pass
451+
447452 try :
448453 return self .map [self .idProperty ]
449454 except :
@@ -877,13 +882,18 @@ def isClickable(self):
877882 return self .__getattr__ ('isClickable' )()
878883
879884 def variableNameFromId (self ):
880- m = ID_RE .match (self .getUniqueId ())
881- if m :
882- var = m .group (1 )
883- if m .group (3 ):
884- var += m .group (3 )
885- if re .match ('^\d' , var ):
886- var = 'id_' + var
885+ _id = self .getId ()
886+ if _id :
887+ var = _id .replace ('.' , '_' ).replace (':' , '___' ).replace ('/' , '_' )
888+ else :
889+ _id = self .getUniqueId ()
890+ m = ID_RE .match (_id )
891+ if m :
892+ var = m .group (1 )
893+ if m .group (3 ):
894+ var += m .group (3 )
895+ if re .match ('^\d' , var ):
896+ var = 'id_' + var
887897 return var
888898
889899 def writeImageToFile (self , filename , format = "PNG" ):
Original file line number Diff line number Diff line change @@ -18,7 +18,7 @@ ___________________/ /__/ /__/ /__/ /________________________________
1818
1919'''
2020
21- __version__ = '5.0 .0'
21+ __version__ = '5.3 .0'
2222
2323import re
2424import sys
@@ -242,9 +242,9 @@ def printFindViewWithContentDescription(view, useregexp):
242242 if autoRegexp .match (contentDescription ):
243243 contentDescription = autoRegexp .pattern
244244 break
245- contentDescription = "re.compile('''%s''')" % contentDescription
245+ contentDescription = "re.compile(u '''%s''')" % contentDescription
246246 else :
247- contentDescription = "'''%s'''" % contentDescription
247+ contentDescription = "u '''%s'''" % contentDescription
248248 print '%s = %svc.findViewWithContentDescriptionOrRaise(%s)' % (var , prefix , contentDescription )
249249 elif kwargs1 [VERBOSE ]:
250250 warnings .warn ('View with id=%s has no content-description' % view .getUniqueId ())
@@ -258,7 +258,8 @@ def printFindViewById(view):
258258 '''
259259
260260 var = variableNameFromIdOrKey (view )
261- print '%s = %svc.findViewByIdOrRaise("%s")' % (var , prefix , view .getUniqueId ())
261+ _id = view .getId () if view .getId () else view .getUniqueId ()
262+ print '%s = %svc.findViewByIdOrRaise("%s")' % (var , prefix , _id )
262263
263264def traverseAndPrint (view ):
264265 '''
You can’t perform that action at this time.
0 commit comments