代码拉取完成,页面将自动刷新
"""
# ————————————————
# @Time : 2021/3/9 11:32
# @Author : zgh
# @Email : 849080458@qq.com
# @File : APP_test.py
# ————————————————
"""
import multiprocessing as np
import uiautomator2 as u2
import subprocess
import time
def getphonelist(): # 获取手机设备
cmd = r'adb devices' # % apk_file
pr = subprocess.Popen(cmd, stdout=subprocess.PIPE, shell=True)
pr.wait() # 不会马上返回输出的命令,需要等待
out = pr.stdout.readlines() # out = pr.stdout.read().decode("UTF-8")
devices = []
for i in (out)[1:-1]:
device = str(i).split("\\")[0].split("'")[-1]
devices.append(device)
print(devices)
return devices # 手机设备列表
def app_case(i): # 执行用例
d = u2.connect(getphonelist()[int(i)]) # d = u2.connect('192.168.1.117')# uiautomator2 连接手机
MultiDevice(d)
def MultiDevice(d): # 功能执行
d(text="微信").click()
d.xpath(
'//*[@resource-id="com.tencent.mm:id/f67"]/android.widget.LinearLayout[1]/android.widget.RelativeLayout[1]/android.widget.ImageView[1]').click()
d(resourceId="com.tencent.mm:id/av9", text="我要体检").click()
d(text="套餐购买").click()
time.sleep(20)
d.press("home")
d.app_stop('com.vphone.launcher')
# d.app_clear('com.vphone.launcher')
# d.app_stop_all()
def main(): # 多进程
for i in range(len(getphonelist())): # 有几个设备起几个进程
p = np.Process(target=app_case, args=(str(i)))
p.start()
if __name__ == '__main__':
# getphonelist()
main()
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。