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设计】。

相关文章

C#返回当前系统所有可用驱动器符号的方法

本文实例讲述了C#返回当前系统所有可用驱动器符号的方法。分享给大家供大家参考。具体如下: // The initial C# code for the "plain" WMI que...

python基础教程项目四之新闻聚合

《python基础教程》书中的第四个练习,新闻聚合。现在很少见的一类应用,至少我从来没有用过,又叫做Usenet。这个程序的主要功能是用来从指定的来源(这里是Usenet新闻组)收集信息...

如何利用Pyecharts可视化微信好友

如何利用Pyecharts可视化微信好友

前言 最近在研究 pyecharts  的用法,它是 python 的一个可视化工具,然后就想着结合微信来一起玩 不多说,直接看效果: 环境配置 pip ins...

设计模式中的原型模式在Python程序中的应用示例

原型模式: 原型实例指定创建对象的种类,并且通过拷贝这些原型创建新的对象。 原型模式本质就是克隆对象,所以在对象初始化操作比较复杂的情况下,很实用,能大大降低耗时,提高性能,因为“不用重...

pytorch 常用线性函数详解

Pytorch的线性函数主要封装了Blas和Lapack,其用法和接口都与之类似。 常用的线性函数如下: 函数 功能...