11#!/usr/bin/env python
22# -*- coding: utf-8 -*-
33'''
4- Copyright (C) 2013-2018 Diego Torres Milano
4+ Copyright (C) 2013-2019 Diego Torres Milano
55Created on Mar 28, 2013
66
77Culebra helps you create AndroidViewClient scripts generating a working template that can be
@@ -22,6 +22,8 @@ ___________________/ /__/ /__/ /__/ /________________________________
2222
2323from __future__ import print_function
2424
25+ from culebratester_client import WindowHierarchy
26+
2527__version__ = '20.0.0'
2628
2729import calendar
@@ -226,7 +228,7 @@ def variableNameFromIdOrKey(view):
226228 @return: the variable name from the id
227229 '''
228230
229- var = view .variableNameFromId ()
231+ var = View .variableNameFromId (view )
230232 if options [CulebraOptions .USE_DICTIONARY ]:
231233 return '%sviews[\' %s\' ]' % (
232234 prefix , notNull (dictionaryKeyFrom (options [CulebraOptions .DICTIONARY_KEYS_FROM ], view ), var ))
@@ -257,7 +259,9 @@ def printFindViewWithText(view, useregexp, op=Operation.ASSIGN, arg=None):
257259 @param view: the View
258260 '''
259261
260- text = view .getText ()
262+ text = view .text
263+ if callable (text ):
264+ text = text ()
261265 isUnicode = isinstance (text , str )
262266 if isUnicode and sys .stdout .encoding is None :
263267 warnings .warn ('''\
@@ -344,7 +348,7 @@ def printFindViewWithContentDescription(view, useregexp, op=Operation.ASSIGN, ar
344348 @param view: the View
345349 '''
346350
347- contentDescription = view .getContentDescription ()
351+ contentDescription = view .content_description
348352 if contentDescription :
349353 var = variableNameFromIdOrKey (view )
350354 if useregexp :
@@ -427,7 +431,7 @@ def printFindViewById(view, op=Operation.ASSIGN, arg=None):
427431 '''
428432
429433 var = variableNameFromIdOrKey (view )
430- _id = view .getId () if view .getId () else view .getUniqueId ()
434+ _id = view .id if view .id else view .unique_id
431435 if op == Operation .ASSIGN :
432436 if options [CulebraOptions .MULTI_DEVICE ]:
433437 logAction ('finding view with id=%s on ${serialno}' % _id )
@@ -516,6 +520,8 @@ def printDump(window, dump=None):
516520 print ('%s%svc.dump(window=%s)' % (indent , prefix , window ))
517521
518522 if not options [CulebraOptions .DO_NOT_VERIFY_SCREEN_DUMP ]:
523+ if DEBUG :
524+ print ('printing dump: %s' % dump .__class__ .__name__ )
519525 printTraverse (dump )
520526
521527
@@ -736,7 +742,10 @@ def traverseAndPrint(view):
736742 '''
737743
738744 if DEBUG :
739- print ("traverseAndPrint(view=%s)" % view .getId (), file = sys .stderr )
745+ print ("🐞 traverseAndPrint(view=%s)" % view .id , file = sys .stderr )
746+ if type (view ) == WindowHierarchy :
747+ # The root element is a WindowHierarchy (id=hierarchy)
748+ return
740749 if options [CulebraOptions .VERBOSE_COMMENTS ]:
741750 printVerboseComments (view )
742751 if options [CulebraOptions .FIND_VIEWS_BY_ID ]:
@@ -748,7 +757,7 @@ def traverseAndPrint(view):
748757 if options [CulebraOptions .SAVE_VIEW_SCREENSHOTS ]:
749758 _format = 'PNG'
750759 filename = options [
751- CulebraOptions .SAVE_VIEW_SCREENSHOTS ] + os .sep + view .variableNameFromId () + '.' + _format .lower ()
760+ CulebraOptions .SAVE_VIEW_SCREENSHOTS ] + os .sep + View .variableNameFromId (view ) + '.' + _format .lower ()
752761 printSaveViewScreenshot (view , filename , _format )
753762
754763
@@ -1021,7 +1030,7 @@ def printScriptHeader():
10211030 print ('''%s
10221031# -*- coding: utf-8 -*-
10231032"""
1024- Copyright (C) 2013-2018 Diego Torres Milano
1033+ Copyright (C) 2013-2019 Diego Torres Milano
10251034Created on %s by Culebra v%s
10261035 __ __ __ __
10271036 / \ / \ / \ / \
0 commit comments