python 实现手机自动拨打电话的方法(通话压力测试)

yipeiwu_com6年前Python基础

现在能用自动化实现的,尽量使用自动化程序去操作,代替人工去操作,更有效率。

今天说下用python结合adb命令去实现安卓手机端的通话压力测试。

#操作前先在设置里打开power键可以结束通话按钮,否则会导致代码报错
from time import sleep
import os

def test_call(number1,number2,number3,number4,number5):
 #拨打电话
 call = os.popen('adb shell am start -a android.intent.action.CALL -d tel:{}'.format(number1))
 sleep(20)
 #挂断电话
 Hangup = os.popen('adb shell input keyevent 26')
 sleep(5)
 call = os.popen('adb shell am start -a android.intent.action.CALL -d tel:{}'.format(number2))
 sleep(5)
 # 挂断电话
 Hangup = os.popen('adb shell input keyevent 26')
 sleep(5)
 call = os.popen('adb shell am start -a android.intent.action.CALL -d tel:{}'.format(number3))
 sleep(20)
 # 挂断电话
 Hangup = os.popen('adb shell input keyevent 26')
 sleep(5)
 call = os.popen('adb shell am start -a android.intent.action.CALL -d tel:{}'.format(number4))
 sleep(20)
 # 挂断电话
 Hangup = os.popen('adb shell input keyevent 26')
 sleep(5)
 call = os.popen('adb shell am start -a android.intent.action.CALL -d tel:{}'.format(number5))
 sleep(20)
 # 挂断电话
 Hangup = os.popen('adb shell input keyevent 26')
 sleep(2)


#你可以修改你要通话的号码如下:
number1 = 10010
number2 = 10086
number3 = 10011
number4 = 12580
number5 =114

#执行代码:
test_call(number1,number2,number3,number4,number5)

#截图
ScreenShot = os.popen('adb shell /system/bin/screencap -p /sdcard/xie.png')

#将截图保存到电脑
SaveScreenShot = os.popen('adb pull /sdcard/xie.png')

以上这篇python 实现手机自动拨打电话的方法(通话压力测试)就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持【听图阁-专注于Python设计】。

相关文章

python和shell获取文本内容的方法

这两天搞脚本,花费不少时间。 Python和Shell都可以获取文本内容,网上许多资料介绍的都不具体。简单的使用Python和Shell写了脚本。 做一些笔记沉淀一下。 1、Python...

Face++ API实现手势识别系统设计

Face++ API实现手势识别系统设计

        通过普通摄像头拍摄出的照片来进行识别是存在很大的困难的,但是有困难才能找到更好的方法去解决。在百度上...

python实时监控cpu小工具

python实时监控cpu小工具

本文实例为大家分享了python实时监控cpu的工具,供大家参考,具体内容如下 虽然写的很不完善,但是当练手吧,对于实时监控cpu还是有点用处的,虽然android studio已经提供...

Python smallseg分词用法实例分析

本文实例讲述了Python smallseg分词用法。分享给大家供大家参考。具体分析如下: #encoding=utf-8 #import psyco #psyco.full()...

python获得一个月有多少天的方法

本文实例讲述了python获得一个月有多少天的方法。分享给大家供大家参考。具体分析如下: 在python的datetime模块中没有一个月有多少天的方法,但是可以使用calendar模块...