from com.android.monkeyrunner import MonkeyRunner, MonkeyDevice, MonkeyImage
import os
import datetime
import time
import shutil
import subprocess
class Collect_Infromation():
def __init__(self,host):
self.host = host
self.collect_information = "collect_information"
self.packagename = None
self.host = None
self.pid = None
self.packagename_activity = None
def device_power_information(self,host):
cmds = []
if host == None:
content_information = os.popen('adb shell dumpsys batterystats | more').readlines()
else:
cmds.append('adb -s %s shell dumpsys batterystats | more' %host)
print(cmds)
for adb_path in cmds:
content_information = os.popen(adb_path).readlines()
return content_information
def runing_pacename_and_activity_name(self,host):
cmds = []
if host == None:
content_information = os.popen("adb shell 'logcat | grep START'").readlines()
else:
cmds.append('adb -s %s shell logcat | grep START' %host)
for adb_path in cmds:
content_information = os.popen(adb_path).readlines()
return content_information
def start_app(self,packagename_activity,host):
cmds = []
if host == None:
content_information = os.popen("adb shell am start -W -n " + packagename_activity)
else:
cmds.append('adb -s %s shell am start -W -n %s'%host%packagename_activity)
for adb_path in cmds:
content_information = os.popen(adb_path).readlines()
return content_information
def kill_app (self,packagename,host):
cmds = []
if host == None:
content_information = os.popen("adb shell am force-stop &#
Monkeyrunner 编写自动化脚本
最新推荐文章于 2023-10-02 06:00:00 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)