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秒钟

 

上一篇:Python subprocess


下一篇:selenium简单识别验证码