您的当前位置:首页正文

uiautomator2基本例子

2020-11-20 来源:客趣旅游网
uiautomator2基本例⼦

uiautomator2基本例⼦

# coding:utf-8

import uiautomator2 as u2import timeimport subprocessimport shutil

# adb_connect_initcmds = [

\"taskkill /f /im adb.exe\", 'start adb',

\"adb connect 127.0.0.1:62001\", \"adb devices\",]

for cmd in cmds: print(10*\"--\")

result = subprocess.Popen(cmd, shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE) print(result.stdout.read().decode(\"gbk\")) time.sleep(2)# 连接APP

d = u2.connect('127.0.0.1:62001')

# 关闭之前旧的APP,停⽌所有正在进⾏的appd.app_stop_all()

# 启动APP

d.app_start(\"com.lianjia.beike\")time.sleep(5)

print('开始。。。')

time.sleep(5) # 等5秒钟

因篇幅问题不能全部显示,请点此查看更多更全内容