1 Star 0 Fork 0

猛猛小蚂蚁/python_WEB_Framework

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
APP_main.py 1.61 KB
一键复制 编辑 原始数据 按行查看 历史
zhanggh 提交于 2021-08-12 13:01 . >new porject
"""
# ————————————————
# @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()
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
HTML
1
https://gitee.com/zhanggh8023/python_WEB_Framework.git
git@gitee.com:zhanggh8023/python_WEB_Framework.git
zhanggh8023
python_WEB_Framework
python_WEB_Framework
master

搜索帮助

D67c1975 1850385 1daf7b77 1850385