其他分享
首页 > 其他分享> > uiautomator2基本例子

uiautomator2基本例子

作者:互联网

uiautomator2基本例子

# coding:utf-8
import uiautomator2 as u2
import timeimport subprocess
import shutil

# adb_connect_init
cmds = [
    "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,停止所有正在进行的app
d.app_stop_all()


# 启动APP
d.app_start("com.lianjia.beike")
time.sleep(5)
print('开始。。。')
time.sleep(5)            # 等5秒钟

 

标签:基本,app,subprocess,PIPE,例子,adb,connect,print,uiautomator2
来源: https://www.cnblogs.com/cforcnb/p/14499287.html