File tree Expand file tree Collapse file tree 2 files changed +19
-3
lines changed
src/com/dtmilano/android/uiautomator Expand file tree Collapse file tree 2 files changed +19
-3
lines changed Original file line number Diff line number Diff line change 2020
2121from __future__ import print_function
2222
23- __version__ = '21.13 .0'
23+ __version__ = '21.14 .0'
2424
2525import json
2626import os
@@ -430,6 +430,22 @@ def find_objects(self, **kwargs):
430430 body = culebratester_client .Selector (** kwargs )
431431 return self .uiAutomatorHelper .api_instance .ui_device_find_objects_post (body = body )
432432
433+ def has_object (self , ** kwargs ) -> bool :
434+ """
435+ Has an object.
436+ Invokes GET or POST method depending on the arguments passed.
437+
438+ :see https://github.com/dtmilano/CulebraTester2-public/blob/master/openapi.yaml
439+ :param kwargs:
440+ :return: True or False
441+ """
442+ if 'body' in kwargs :
443+ return self .uiAutomatorHelper .api_instance .ui_device_has_object_post (** kwargs ).value
444+ if self .some (['resource_id' , 'ui_selector' , 'by_selector' ], kwargs ):
445+ return self .uiAutomatorHelper .api_instance .ui_device_has_object_get (** kwargs ).value
446+ body = culebratester_client .Selector (** kwargs )
447+ return self .uiAutomatorHelper .api_instance .ui_device_has_object_post (body = body ).value
448+
433449 def press_back (self ):
434450 """
435451 Presses BACK.
Original file line number Diff line number Diff line change @@ -1052,12 +1052,12 @@ def printTestUiAutomatorHelper(selector):
10521052 indentation = indent + ' ' * 4
10531053 # FIXME: we need has_object POST
10541054 # We are just raising the exception if the object is not found, we could trap it
1055- for line in f'{ indent } assert { prefix } helper.ui_device.find_object (body={ selector } )' .splitlines ():
1055+ for line in f'{ indent } assert { prefix } helper.ui_device.has_object (body={ selector } )' .splitlines ():
10561056 if not indented_line :
10571057 indented_line = line
10581058 else :
10591059 indented_line = f'{ indented_line } \n { indentation } { line } '
1060- print (f' { indented_line } is not None' )
1060+ print (indented_line )
10611061
10621062
10631063def printOperation (view , op , * args ):
You can’t perform that action at this time.
0 commit comments