forked from dtmilano/AndroidViewClient
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add culebra-calculator-simple-test example
- Loading branch information
Showing
2 changed files
with
143 additions
and
0 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
143 changes: 143 additions & 0 deletions
143
examples/helper/culebra/culebra-calculator-simple-test.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,143 @@ | ||
#! /usr/bin/env python3 | ||
# -*- coding: utf-8 -*- | ||
""" | ||
Copyright (C) 2013-2022 Diego Torres Milano | ||
Created on 2023-09-03 by Culebra v22.6.0 | ||
__ __ __ __ | ||
/ \ / \ / \ / \ | ||
____________________/ __\/ __\/ __\/ __\_____________________________ | ||
___________________/ /__/ /__/ /__/ /________________________________ | ||
| / \ / \ / \ / \ \___ | ||
|/ \_/ \_/ \_/ \ o \ | ||
\_____/--< | ||
@author: Diego Torres Milano | ||
@author: Jennifer E. Swofford (ascii art snake) | ||
""" | ||
|
||
|
||
import os | ||
import re | ||
import sys | ||
import time | ||
|
||
from com.dtmilano.android.viewclient import ViewClient, KEY_EVENT | ||
|
||
|
||
TAG = 'CULEBRA' | ||
_s = 5 | ||
_v = '--verbose' in sys.argv | ||
pid = os.getpid() | ||
|
||
|
||
kwargs1 = {'verbose': False, 'ignoresecuredevice': False, 'ignoreversioncheck': False} | ||
device, serialno = ViewClient.connectToDeviceOrExit(**kwargs1) | ||
|
||
kwargs2 = {'forceviewserveruse': False, 'startviewserver': True, 'autodump': False, 'ignoreuiautomatorkilled': True, 'compresseddump': True, 'useuiautomatorhelper': True, 'debug': {}} | ||
vc = ViewClient(device, serialno, **kwargs2) | ||
|
||
helper = vc.uiAutomatorHelper | ||
|
||
obj_ref = helper.until.find_object(body={'checkable': False, | ||
'checked': None, | ||
'clazz': 'android.widget.ImageButton', | ||
'clickable': True, | ||
'depth': None, | ||
'desc': '3', | ||
'has_child': None, | ||
'has_descendant': None, | ||
'index': None, | ||
'instance': None, | ||
'pkg': 'com.google.android.calculator', | ||
'res': 'com.google.android.calculator:id/digit_3', | ||
'scrollable': None, | ||
'text': ''}) | ||
response = helper.ui_device.wait(oid=obj_ref.oid) | ||
helper.ui_object2.click(oid=response['oid']) | ||
helper.ui_device.wait_for_window_update() | ||
|
||
obj_ref = helper.until.find_object(body={'checkable': False, | ||
'checked': None, | ||
'clazz': 'android.widget.ImageButton', | ||
'clickable': True, | ||
'depth': None, | ||
'desc': 'multiply', | ||
'has_child': None, | ||
'has_descendant': None, | ||
'index': None, | ||
'instance': None, | ||
'pkg': 'com.google.android.calculator', | ||
'res': 'com.google.android.calculator:id/op_mul', | ||
'scrollable': None, | ||
'text': ''}) | ||
response = helper.ui_device.wait(oid=obj_ref.oid) | ||
helper.ui_object2.click(oid=response['oid']) | ||
helper.ui_device.wait_for_window_update() | ||
|
||
obj_ref = helper.until.find_object(body={'checkable': False, | ||
'checked': None, | ||
'clazz': 'android.widget.ImageButton', | ||
'clickable': True, | ||
'depth': None, | ||
'desc': '2', | ||
'has_child': None, | ||
'has_descendant': None, | ||
'index': None, | ||
'instance': None, | ||
'pkg': 'com.google.android.calculator', | ||
'res': 'com.google.android.calculator:id/digit_2', | ||
'scrollable': None, | ||
'text': ''}) | ||
response = helper.ui_device.wait(oid=obj_ref.oid) | ||
helper.ui_object2.click(oid=response['oid']) | ||
helper.ui_device.wait_for_window_update() | ||
|
||
obj_ref = helper.until.find_object(body={'checkable': False, | ||
'checked': None, | ||
'clazz': 'android.widget.ImageButton', | ||
'clickable': True, | ||
'depth': None, | ||
'desc': 'equals', | ||
'has_child': None, | ||
'has_descendant': None, | ||
'index': None, | ||
'instance': None, | ||
'pkg': 'com.google.android.calculator', | ||
'res': 'com.google.android.calculator:id/eq', | ||
'scrollable': None, | ||
'text': ''}) | ||
response = helper.ui_device.wait(oid=obj_ref.oid) | ||
helper.ui_object2.click(oid=response['oid']) | ||
helper.ui_device.wait_for_window_update() | ||
|
||
assert helper.ui_device.has_object(body={'checkable': False, | ||
'checked': None, | ||
'clazz': 'android.widget.TextView', | ||
'clickable': False, | ||
'depth': None, | ||
'desc': '', | ||
'has_child': None, | ||
'has_descendant': None, | ||
'index': None, | ||
'instance': None, | ||
'pkg': 'com.google.android.calculator', | ||
'res': 'com.google.android.calculator:id/result_final', | ||
'scrollable': None, | ||
'text': '6'}) | ||
|
||
obj_ref = helper.until.find_object(body={'checkable': False, | ||
'checked': None, | ||
'clazz': 'android.widget.ImageButton', | ||
'clickable': True, | ||
'depth': None, | ||
'desc': 'clear', | ||
'has_child': None, | ||
'has_descendant': None, | ||
'index': None, | ||
'instance': None, | ||
'pkg': 'com.google.android.calculator', | ||
'res': 'com.google.android.calculator:id/clr', | ||
'scrollable': None, | ||
'text': ''}) | ||
response = helper.ui_device.wait(oid=obj_ref.oid) | ||
helper.ui_object2.click(oid=response['oid']) | ||
helper.ui_device.wait_for_window_update() |