android系统一个测试用例python实现(利用adb方法)

 

 

# -*- coding:UTF-8 -*-
import os
import sys
import time

#from com.android.monkeyrunner import MonkeyRunner, MonkeyDevice, MonkeyImage

rootpath  = os.path.split(os.path.realpath(sys.argv[0]))[0]
screenPath = "D:\\ceshi\\1\\" #保存路径
#device = MonkeyRunner.waitForConnection()
#MonkeyRunner.sleep(1)#休眠1s
time.sleep(5)
test_times = 100  #设置测试次数

numberphone = input("请输入要呼叫的号码:")#由用户输入呼叫号码
for i in range(0,test_times):

   # 1.终端发起半双工单呼,讲状态5s,等待3s系统超时释放;
   os.popen("adb shell am start com.zzzz/.ui.contacts.rrrrActivity555")#打开拨号盘
   os.popen("adb shell input keyevent 4")#按返回键先退出
   os.popen("adb shell am start com.zzzz/.ui.contacts.rrrActivity555")#
   os.popen("adb shell input tap 136 1190")#点击拨号
   os.popen("adb shell input tap 80 12960")#调出拨号盘
   os.popen("adb shell input text %s"%numeberphone)#输入单呼号码
   
   os.popen('adb shell "sendevent /dev/input/event0 1 522 1 && sendevent /dev/input/event0 0 0 0"')  #长按PTT键
   time.sleep(5)
   os.popen('adb shell "sendevent /dev/input/event0 1 522 0 && sendevent /dev/input/event0 0 0 0"')
   time.sleep(3)

   
   # 2.发起语音组呼,讲状态5s,等待3s系统超时释放
   os.popen("adb shell input keyevent 3")#按Home键先退出
   
   os.popen('adb shell "sendevent /dev/input/event0 1 522 1 && sendevent /dev/input/event0 0 0 0"')  #长按PTT键
   time.sleep(5)
   os.popen('adb shell "sendevent /dev/input/event0 1 522 0 && sendevent /dev/input/event0 0 0 0"')
   time.sleep(3)
   
   
   # 3.发起视频组呼,讲状态5s,等待3s系统超时释放;
   os.popen("adb shell input keyevent 3")#按Home键先退出
   
   os.popen("adb shell input keyevent 103")#按紧急键(视频键) 
   os.popen('adb shell "sendevent /dev/input/event0 1 522 1 && sendevent /dev/input/event0 0 0 0"')  #长按PTT键
   time.sleep(5)
   os.popen('adb shell "sendevent /dev/input/event0 1 522 0 && sendevent /dev/input/event0 0 0 0"')
   time.sleep(3)
   

   time.sleep(5)
   # 4.终端发送一条B-TrunC短信;
   os.popen("adb shell input keyevent 3")#按Home键先退出
   
   os.popen("adb shell am start com.zzzz/.ui.sms.ActivitySms")#打开B-TrunC短信
   os.popen("adb shell input tap 369 1307")#点击新建短信
   os.popen("adb shell input tap 152 226")#点击输入号码
   os.popen("adb shell input text %s"%numeberphone)#输入号码
   os.popen("adb shell input tap 166 680")#点击新建短信
   os.popen("adb shell input text aaaaSend")#输入单呼号码
   os.popen("adb shell input tap 640 688")#点击发送
   

   time.sleep(5)
   #5.进入app,对群组发起视频推送,持续30s,结束视频推送。
   device.press('KEYCODE_HOME',MonkeyDevice.DOWN)#先返回主界面
   
   os.popen("adb shell am start com.zzzz/.ui.ddddActivity")#打开app
   
   os.popen("adb shell input tap 610 1263")#点击通讯录
   os.popen("adb shell input tap 594 99")#点击群组
   os.popen("adb shell input tap 187 199")#点击搜索
   os.popen("adb shell input text 模拟用户测试")#输入单呼号码
   os.popen("adb shell input tap 288 337")#选择群组
   os.popen("adb shell input tap 291 1304")#点击推送
   time.sleep(30)
   os.popen("adb shell input tap 481 722")#随便点击一个位置
   os.popen("adb shell input tap 671 677")#点击结束
   
   result1 = device.takeSnapshot().getSubImage((0, 0, 530, 950)) #截图整屏
   now = time.strftime("%Y-%m-%d-%H-%M-%S") #获取本地时间,然后命名,防止覆盖上张图片
   result1.writeToFile(screenPath + now + '.png','png')#截图
   time.sleep(5)
   
   

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

测试狂人

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值