#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(三) 随手练习测试脚本的更多相关文章

  1. Android自动化测试 - MonkeyRunner(二) 锤子便签测试脚本

    来源于:http://testerhome.com/topics/878 # encoding=utf-8 #导入python中自带的time模块和sys模块,脚本中都要用到它们. import ti ...

  2. Android自动化测试 - MonkeyRunner(一)介绍

    MonkeyRunner介绍: MonkeyRunner是Google提供的一个基于坐标点的Android黑盒自动化测试工具. Monkeyrunner工具提供了一套API让用户/测试人员来调用,调用 ...

  3. Android 自动化测试及性能数据采集的 Python 脚本

    文主要介绍一个基于 uiautomator2 封装的一个 Python 库 android-catcher ,该库的功能主要有对 Android 设备进行 UI 自动化测试 和 采集手机性能数据 ,适 ...

  4. Appium环境的安装与配置,Python测试脚本测试

    Appium自动化测试系列1 - Appium环境的安装与配置 发表于4个月前(2015-01-27 14:34)   阅读(803) | 评论(0) 0人收藏此文章, 我要收藏 赞0 寻找 会’偷懒 ...

  5. Android 自动化测试——Monkey测试

    Android自带了很多方便的测试工具和方法,包括我们常用的单元测试.Robotium测试.Monkey测试.MonkeyRunner测试.senevent模拟等.这些方法对于我们编写高质量的APP十 ...

  6. Android自己的自动化测试Monkeyrunner和用法示例

    眼下android SDK在配有现成的测试工具monkey 和 monkeyrunner两. 也许我们不看一样的兄弟名字.但事实是完全跑了两个完全不同的工具.在测试的不同区域的应用程序.总体,monk ...

  7. 锤子便签的 monkeyrunner 测试脚本(转)

    https://testerhome.com/topics/878 MonkeyRunner可能大家已经听过无数次了,大家在网上也看过了各种关于的它的资料了,我这里就不再过多的啰嗦它的用途了,它可以对 ...

  8. Android自动化测试中Monkeyrunner详解

    之前有写过monkey测试详细说明,几天就说说monkeyrunner. monkeyrunner工具提供了一个API,使用此API写出的程序可以在Android代码之外控制Android设备和模拟器 ...

  9. HTML脚本配置Android自动化测试

    说明   在项目配置完基于robotium框架下的自动化测试用例后发现虽然用代码配置测试用例虽然较为灵活,但是如果编写较为全面的测试用例则必然会消耗大量开人员的精力,并且对于用例的后期维护也是很大一部 ...

随机推荐

  1. SlimDX.dll安装之后所在位置

    C:\Windows\Microsoft.NET\assembly\GAC_64\SlimDX\v4.0_4.0.13.43__b1b0c32fd1ffe4f9\SlimDX.dll

  2. Java IO流总结

    Java IO流分类以及主要使用方式如下: IO流 |--字节流 |--字节输入流 InputStream: int read();//一次读取一个字节 int read(byte[] bys);// ...

  3. CUDA中并行规约(Parallel Reduction)的优化

    转自: http://hackecho.com/2013/04/cuda-parallel-reduction/ Parallel Reduction是NVIDIA-CUDA自带的例子,也几乎是所有C ...

  4. Index on DB2 for z/OS: DB2 for z/OS 的索引

    可以创建在任何表上的索引: Unique Index:An index that ensures that the value in a particular column or set of col ...

  5. Java Web基础——Action+Service +Dao三层的功能划分

    1. Action/Service/DAO简介: Action是管理业务(Service)调度和管理跳转的. Service是管理具体的功能的. Action只负责管理,而Service负责实施. D ...

  6. JustSniffer

    http://blog.csdn.net/cnbird2008/article/details/5875781

  7. C#的LINQ to Object

    using System; using System.Collections; using System.Collections.Generic; using System.IO; using Sys ...

  8. C#接扣和抽象类

    什么是接口? 接口是包含一组虚方法的抽象类型,其中每一种方法都有其名称.参数和返回值.接口方法不能包含任何实现,CLR允许接口可以包含事件.属性.索引器.静态方法.静态字段.静态构造函数以及常数.但是 ...

  9. Getting Started with Blocks

    本文来源为:developer.apple.com,仅仅是博主练习排版所用. Getting Started with Blocks The following sections help you t ...

  10. hdu 2232 矩阵 ***

    一天四个不同的机器人a.b.c和d在一张跳舞毯上跳舞,这是一张特殊的跳舞毯,他由4个正方形毯子组成一个大的正方形毯子,一开始四个机器人分别站在4 块毯子上,舞蹈的每一步机器人可以往临近(两个毯子拥有同 ...