Android自动化测试 - MonkeyRunner(三) 随手练习测试脚本
#coding=utf-8
import os
import time #import MonkeyRunner three module
from com.android.monkeyrunner import MonkeyRunner, MonkeyDevice, MonkeyImage
runComponent = "com.dest.mr/.ui.home.HomeLauncherNew" path = 'd:/pic/'
logpath = 'd:/log/' #new log file.txt
log = open(logpath + 'dest' + ".txt",'w') #connection device
device = MonkeyRunner.waitForConnection() if not device:
log.write('connection failed \n' )
sys.exit(1)
else:
log.write('connection passed \n') device.startActivity(component = runComponent)
time.sleep(5) #device.shell("logcat | grep 'com.dest.mr' > sdcard/destlog.txt")
#os.system('''adb logcat | findstr "com.dest.mr" >> d:/log/logcat.txt''') for i in range(3):
#save log to file.txt
log.write('start app....' + str(i) + '\n')
desthome = device.takeSnapshot()
desthome.writeToFile(path + 'desthome' + str(i) + '.png','png')
#import home pictures for comparing the results
homeTure = MonkeyRunner.loadImageFromFile('d:/pic/Tdesthome.png') if(desthome.sameAs(homeTure,0.9)):
print 'desthome pic is the same \n'
log.write ('test passed \n')
else:
print 'test byebye \n'
log.write ('test failed \n') #open userinfo
device.touch(850,68,'DOWN_AND_UP')
time.sleep(2)
userinfo = device.takeSnapshot()
userinfo.writeToFile(path + 'userinfo' + str(i) + '.png','png') ufoTure = MonkeyRunner.loadImageFromFile('d:/pic/Tuserinfo.png') if(userinfo.sameAs(ufoTure,0.75)):
print 'userinfo pic is the same \n'
log.write ('userinfo test passed \n')
else:
print 'userinfo pic is not the same'
log.write ('userinfo test failed \n') #click mobile, into myinfo page
device.touch(550,200,'DOWN_AND_UP')
time.sleep(2)
myinfo = device.takeSnapshot()
myinfo.writeToFile(path + 'myinfo' + str(i) + '.png','png')
device.drag((500,550),(300,250),0.5)
time.sleep(2) device.press('KEYCODE_BACK','DOWN_AND_UP')
time.sleep(2)
device.touch(60,80,'DOWN_AND_UP')
time.sleep(2)
Android自动化测试 - MonkeyRunner(三) 随手练习测试脚本的更多相关文章
- Android自动化测试 - MonkeyRunner(二) 锤子便签测试脚本
来源于:http://testerhome.com/topics/878 # encoding=utf-8 #导入python中自带的time模块和sys模块,脚本中都要用到它们. import ti ...
- Android自动化测试 - MonkeyRunner(一)介绍
MonkeyRunner介绍: MonkeyRunner是Google提供的一个基于坐标点的Android黑盒自动化测试工具. Monkeyrunner工具提供了一套API让用户/测试人员来调用,调用 ...
- Android 自动化测试及性能数据采集的 Python 脚本
文主要介绍一个基于 uiautomator2 封装的一个 Python 库 android-catcher ,该库的功能主要有对 Android 设备进行 UI 自动化测试 和 采集手机性能数据 ,适 ...
- Appium环境的安装与配置,Python测试脚本测试
Appium自动化测试系列1 - Appium环境的安装与配置 发表于4个月前(2015-01-27 14:34) 阅读(803) | 评论(0) 0人收藏此文章, 我要收藏 赞0 寻找 会’偷懒 ...
- Android 自动化测试——Monkey测试
Android自带了很多方便的测试工具和方法,包括我们常用的单元测试.Robotium测试.Monkey测试.MonkeyRunner测试.senevent模拟等.这些方法对于我们编写高质量的APP十 ...
- Android自己的自动化测试Monkeyrunner和用法示例
眼下android SDK在配有现成的测试工具monkey 和 monkeyrunner两. 也许我们不看一样的兄弟名字.但事实是完全跑了两个完全不同的工具.在测试的不同区域的应用程序.总体,monk ...
- 锤子便签的 monkeyrunner 测试脚本(转)
https://testerhome.com/topics/878 MonkeyRunner可能大家已经听过无数次了,大家在网上也看过了各种关于的它的资料了,我这里就不再过多的啰嗦它的用途了,它可以对 ...
- Android自动化测试中Monkeyrunner详解
之前有写过monkey测试详细说明,几天就说说monkeyrunner. monkeyrunner工具提供了一个API,使用此API写出的程序可以在Android代码之外控制Android设备和模拟器 ...
- HTML脚本配置Android自动化测试
说明 在项目配置完基于robotium框架下的自动化测试用例后发现虽然用代码配置测试用例虽然较为灵活,但是如果编写较为全面的测试用例则必然会消耗大量开人员的精力,并且对于用例的后期维护也是很大一部 ...
随机推荐
- September 12th 2016 Week 38th Monday
After all, tomorrow is another day. 不管怎样,明天又是全新的一天. Another day? Maybe. Remember when you reach for ...
- Javascript异步编程方法总结
现在我们有三个函数,f1, f2, f3 按正常的思路我们会这样写代码: function f1 (){}; function f2 (){}; function f3 (){}; //在这里调用函数 ...
- python基础——实例属性和类属性
python基础——实例属性和类属性 由于Python是动态语言,根据类创建的实例可以任意绑定属性. 给实例绑定属性的方法是通过实例变量,或者通过self变量: class Student(objec ...
- Oracle dbms_lock.sleep()存储过程使用技巧-场景-分析-实例
<Oracle dbms_lock.sleep()存储过程使用技巧>-场景-分析-实例 摘要:今天是2014年3月10日,北京,雾霾,下午组织相关部门开会.会议的结尾一名开发工程师找到了我 ...
- NYOJ题目457大小写互换
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAsUAAAIUCAIAAAB9y8bFAAAgAElEQVR4nO3dPW7bTNsG0G8T7r0Qt/
- windows 下的tcping 小插件
如果把插件放在根目录 就要能过cmd切换到根目录 cd \ c:\>tcping -d -t -i 0.06 www.baidu.com 将文件放在c:\WINDOWS\system32目录下, ...
- VS2012/2013 停止调试后,无法刷新页面
- 重温WCF之WCF传输安全(十三)(1)前期准备之证书制作(转)
转载地址:http://www.cnblogs.com/lxblog/archive/2012/09/12/2682372.html 一.WCF中的安全方式 说到安全就会涉及到认证,消息一致性和机密性 ...
- [Tools] 使用work2013发布博客
参考园子里推荐的方式,觉得使用word发布挺好的,尝试了一下,还不错,记录下来备用 参考连接: http://www.cnblogs.com/liuxianan/archive/2013/04/1 ...
- 遍历CallBack对象 和 HHIVE对象
内核中有个PLIST_ENTRY CmpHiveListHead;CmpHiveListHead = &CMHIVE.HiveList; CMHIVE结构如下:kd> dt _CMHIV ...