1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81
| __author__ = "panaihua"
from airtest.core.api import * from poco.drivers.android.uiautomation import AndroidUiautomationPoco import logging import os import time
logger = logging.getLogger("airtest") logger.setLevel(logging.ERROR)
auto_setup(__file__)
poco = AndroidUiautomationPoco(use_airtest_input=True, screenshot_each_action=False)
wake()
stop_app('com.sankuai.meituan')
home()
start_app('com.sankuai.meituan')
sleep(10) poco("免费领水果").click()
sleep(10)
if exists(Template(r"tpl1604041772025.png", record_pos=(0.017, 0.381), resolution=(1080, 2160))): touch(Template(r"tpl1604041788888.png", record_pos=(0.381, -0.484), resolution=(1080, 2160)))
touch(Template(r"tpl1603789796067.png", record_pos=(-0.388, 0.666), resolution=(1080, 2160)))
sleep(5) swipe((527, 2044), (527, 280), duration=3)
sleep(15)
if not exists(Template(r"tpl1603854492318.png", record_pos=(0.007, 0.362), resolution=(1080, 2160))): swipe((527, 2044), (527, 280), duration=3)
assert_exists(Template(r"tpl1603854492318.png", record_pos=(0.007, 0.362), resolution=(1080, 2160)), '玩游戏的按钮不存在')
if exists(Template(r"tpl1603873295969.png", record_pos=(-0.006, 0.51), resolution=(1080, 2160))): touch(Template(r"tpl1603873313059.png", record_pos=(0.009, 0.509), resolution=(1080, 2160))) sleep(5)
touch(Template(r"tpl1603854492318.png", record_pos=(0.007, 0.362), resolution=(1080, 2160)))
sleep(15.0)
assert_not_exists(Template(r"tpl1603798232722.png", record_pos=(0.017, -0.393), resolution=(1080, 2160)), "今日游戏次数已经用完,退出")
touch(Template(r"tpl1603791478271.png", record_pos=(-0.001, 0.165), resolution=(1080, 2160)))
sleep(15.0)
now = time.localtime() path = os.environ.get('BERSERKER_ENV') + '/meituan' if not os.path.exists(path): os.makedirs(path, exist_ok=True)
file_name = '{}/activity-{}.png'.format(path, time.strftime("%Y%m%d-%H", now))
snapshot(file_name)
if exists(Template(r"tpl1603792766280.png", record_pos=(-0.014, 0.256), resolution=(1080, 2160))): touch(Template(r"tpl1603792766280.png", record_pos=(-0.014, 0.256), resolution=(1080, 2160))) else: touch(Template(r"tpl1603855598743.png", record_pos=(-0.007, 0.439), resolution=(1080, 2160)))
sleep(15.0) file_name = '{}/advert-{}.png'.format(path, time.strftime("%Y%m%d-%H", now))
snapshot(file_name)
stop_app('com.sankuai.meituan')
|