【Python】wifi开关测试

#!/usr/bin/python
# -*- coding: UTF-8 -*-
import os
import time

def find_device():
	os.system('adb kill-serve')
	os.system('adb start-server')
	os.system('adb root') 
	os.system('adb remount') 
	print("adb devices")
	os.system('adb devices')

def open_wifi():
	print("open wifi")
	os.system('adb shell svc wifi enable')

def close_wifi():
	print("close wifi")
	os.system('adb shell svc wifi disable')

def open_settings():
	print("open settings")
	os.system('adb shell am start com.android.settings/com.android.settings.Settings')

def get_log(name,count):
	os.system('adb logcat -t 50000 > '+name+count+'.log')

#模拟开关wifi
open_settings()
for i in range(1,20):
	find_device()
	open_wifi()
	time.sleep(5)
	close_wifi()
	count=str(i)
	get_log(name="wifi_open_close",count=count)
print("wifi_open_close finish
")
原文地址:https://www.cnblogs.com/wucaiyun1/p/11018207.html