网络编程
位置:首页>> 网络编程>> Python编程>> python 实现手机自动拨打电话的方法(通话压力测试)

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

作者:shawn xie123  发布时间:2021-03-19 08:10:34 

标签: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')

来源:https://blog.csdn.net/xiezhiming1234/article/details/83478640

0
投稿

猜你喜欢

手机版 网络编程 asp之家 www.aspxhome.com