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

yipeiwu_com5年前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内置模块hashlib、hmac与uuid用法分析

本文实例讲述了Python内置模块hashlib、hmac与uuid用法。分享给大家供大家参考,具体如下: 一、hashlib md5和sha算法通过消息摘要算法生成定长的消息摘要,消息...

Python3+Requests+Excel完整接口自动化测试框架的实现

Python3+Requests+Excel完整接口自动化测试框架的实现

框架整体使用Python3+Requests+Excel:包含对实时token的获取 1、------base -------runmethond.py runmethond:对不同的请...

Python简单实现阿拉伯数字和罗马数字的互相转换功能示例

Python简单实现阿拉伯数字和罗马数字的互相转换功能示例

本文实例讲述了Python实现阿拉伯数字和罗马数字的互相转换功能。分享给大家供大家参考,具体如下: 前面一篇介绍了《Java实现的求解经典罗马数字和阿拉伯数字相互转换问题》,这里来看看P...

python 直接赋值和copy的区别详解

直接赋值和copy的区别: 直接赋值:其实就是对象的引用(别名)。 浅拷贝(copy):拷贝父对象,不会拷贝对象的内部的子对象。 深拷贝(deepcopy): copy 模...

python 实现多维数组转向量

我就废话不多说了,如下所示: >>>from compiler.ast import flatten >>>X matrix([[ ...