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使用KNN算法手写体识别

本文实例为大家分享了用KNN算法手写体识别的具体代码,供大家参考,具体内容如下 #!/usr/bin/python #coding:utf-8 import numpy as...

Python 使用 prettytable 库打印表格美化输出功能

Python 使用 prettytable 库打印表格美化输出功能

pip install prettytable 每次添加一行 from prettytable import PrettyTable # 默认表头:Field 1、Field 2....

Python 解决OPEN读文件报错 ,路径以及r的问题

Python 中 ‘unicodeescape' codec can't decode bytes in position XXX: trun错误解决方案 背景描述 今天在运用Pytho...

使用python turtle画高达

使用python turtle画高达

我就废话不多说了,直接上代码吧! import turtle t=turtle.Turtle() turtle.Turtle().screen.delay(0) tleft=turt...

整理Python最基本的操作字典的方法

Python 中的字典是Python中一个键值映射的数据结构,下面介绍一下如何优雅的操作字典. 1.1 创建字典 Python有两种方法可以创建字典,第一种是使用花括号,另一种是使用内建...