通過python調用adb命令對app進行測試 啟動/停止app


轉於博客  https://blog.csdn.net/sunfengye/article/details/77498935    yipianfeng_ye的專

#啟動apk message = os.popen("adb shell am start -W -n com.qihoo.appstore/.home.MainActivity") for line in message.readlines(): if "ThisTime" in line: print(line.split(":")[1])


import os,time class App(): def __init__(self,pagename,firstActivity): """構造方法""" self.pagename = pagename self.firstActivty= firstActivity self.content="" #執行命令的文本 self.startTime="" #啟動的時間 def startApp(self): """開啟app""" cmd = "adb shell am start -W -n "+self.pagename+self.firstActivty self.content = os.popen(cmd) def stopApp(self): """停止app""" cmd = "adb shell am force-stop "+self.pagename os.popen(cmd) def getStartTime(self): """獲取啟動時間""" for line in self.content.readlines(): if "ThisTime" in line: self.startTime = line.split(":")[1] break return self.startTime 


 
         
         
       


免責聲明!

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



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