python airtest 多線程入門(一)極速版刷視頻


 1 from airtest.core.api import *
 2 from poco.drivers.android.uiautomation import AndroidUiautomationPoco
 3 from airtest.core.android.adb import ADB
 4 from airtest.core.android import Android
 5 import random
 6 import threading
 7 
 8 
 9 def run(id):
10     device = Android(id)
11     poco = AndroidUiautomationPoco(device)
12     time.sleep(5)
13     # 關閉程序
14     device.stop_app("com.ss.android.ugc.aweme.lite")
15     time.sleep(5)
16     # 開啟程序
17     device.start_app("com.ss.android.ugc.aweme.lite")
18     time.sleep(10)
19     i = 0
20     while i < 200000:
21         try:
22             # 滑屏
23             poco.swipe([0.5, 0.8], [0.5, 0.2])
24             t = random.randint(5, 10)
25             time.sleep(t)
26         finally:
27             i = i + 1
28 
29 
30 adbs = ADB()
31 adb_list = [d[0] for d in adbs.devices(state="device")]
32 all_task = []
33 for i in adb_list:
34     t = threading.Thread(target=run, args=(i,))
35     t.setDaemon(True)
36     t.start()
37     all_task.append(t)
38 
40 for t in all_task:
41     t.join()  
42     print("in main: get page success")

沒有判斷關閉或領取彈出來的紅包金幣,需要自己寫


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM