python airtest 批量截取手机屏幕devices+时间戳命名保存图片

 1 import time
 2 from poco.drivers.android.uiautomation import AndroidUiautomationPoco
 3 from airtest.core.android import Android
 4 from airtest.core.android.adb import ADB
 5 import threading
 6 def run(n):
 7     device = Android(n)
 8     poco = AndroidUiautomationPoco(device)
 9     picture_name="{}_{}".format(n, time.strftime('%Y%m%d%H%M%S'))
10     print(picture_name)
11     time.sleep(1)
12     device.snapshot(filename='E:\\11.25\\{}.jpg'.format(picture_name))
13 adbs = ADB()
14 adb_list = [d[0] for d in adbs.devices(state="device")]
15 all_task = []
16 for i in adb_list:
17     t = threading.Thread(target=run, args=(i,))
18     t.setDaemon(True)
19     t.start()
20     all_task.append(t)
21 # 等待线程执行结果
22 for t in all_task:
23     t.join()  # 设置主线程等待子线程结束
24     print("in main: get page success")

 

 


posted @ 2021-12-08 15:46  野猫炫  阅读(324)  评论(0编辑  收藏  举报