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

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

现在能用自动化实现的,尽量使用自动化程序去操作,代替人工去操作,更有效率。

今天说下用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

标签:python,手机,拨打电话
0
投稿

猜你喜欢

  • oracle SQL命令大全

    2009-07-02 11:55:00
  • PyQt5实现暗黑风格的计时器

    2023-07-07 02:49:30
  • Python实现CET查分的方法

    2023-06-13 12:05:51
  • Django开发中的日志输出的方法

    2023-02-24 07:37:17
  • Mysql使用Describe命令判断字段是否存在

    2011-04-25 18:27:00
  • 白鸦:界面烂还是界面设计烂?

    2008-04-03 16:05:00
  • python框架django项目部署相关知识详解

    2023-10-26 02:26:15
  • JavaScript中的this指针用法

    2007-08-26 17:29:00
  • ASP 三层架构 Convert类实现代码

    2011-03-16 11:01:00
  • Python pickle类库介绍(对象序列化和反序列化)

    2021-12-31 00:28:33
  • asp GetString的用法

    2008-06-12 13:46:00
  • PHP设计模式(八)装饰器模式Decorator实例详解【结构型】

    2023-11-24 05:59:31
  • Python 函数装饰器应用教程

    2022-08-17 05:53:24
  • 将ASP纪录集输出成n列表格的方法

    2008-03-19 13:27:00
  • 图标设计常犯的10种错误

    2008-03-06 13:40:00
  • Typecho插件实现添加文章目录的方法详解

    2023-05-25 07:19:04
  • ASP Cookies操作的详细介绍与实例代码

    2011-03-10 10:53:00
  • sp_delete_backuphistory

    2008-06-07 13:59:00
  • 清除代码异味

    2011-05-21 08:34:00
  • PHP isset()与empty()的使用区别详解

    2023-11-21 10:28:39
  • asp之家 网络编程 m.aspxhome.com