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读取中文txt文本的方法

对于python2.7 字符串在Python2.7内部的表示是unicode编码,因此,在做编码转换时,通常需要以unicode作为中间编码,即先将其他编码的字符串解码成unicode,...

python实现支付宝转账接口

python实现支付宝转账接口

由于工作需要使用python开发一个自动转账接口,记录一下开发过程。 首先需要在蚂蚁金服上申请开通开发者账户,有了开发者账户就可以使用沙箱进行开发了。 在开发之前我们需要在沙箱应用中填写...

Python模糊查询本地文件夹去除文件后缀的实例(7行代码)

7行代码实现的,废话不多说,直接上代码: import os,re def fuzzy_search(path): word= input('请输入要查询的内容:') fo...

Python正则表达式介绍

Python正则表达式介绍

注意:本文基于Python2.4完成;如果看到不明白的词汇请记得百度谷歌或维基,whatever。 1. 正则表达式基础 1.1. 简单介绍 正则表达式并不是Python的一部分。正则表...

Python 元组操作总结

Python的元组和列表类似,不同之处在于元组中的元素不能修改(因此元组又称为只读列表),且元组使用小括号而列表使用中括号,如下: tup1=('physics','chemistr...