Skip to content

Commit 927def0

Browse files
committed
Add has object
- Use has object in code generation
1 parent 93a6860 commit 927def0

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

src/com/dtmilano/android/uiautomator/uiautomatorhelper.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
from __future__ import print_function
2222

23-
__version__ = '21.13.0'
23+
__version__ = '21.14.0'
2424

2525
import json
2626
import 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.

tools/culebra

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff 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

10631063
def printOperation(view, op, *args):

0 commit comments

Comments
 (0)