1. Android Monkey 实现操作流程:
准备:在eclipse里安装Phyon插件,可以选择在线安装,也可以下载zip解压后放在eclipse安装目录的dropins下,如 : /personal/software/android_developtools/adt-bundle-mac-x86_64-20130522/eclipse/dropins/PyDev 2.8.2
插件准备就绪就重启eclipse,检验PyDev是否正常工作,然后开始MonkeyRunner测试:
第一步:
gufeitekiMacBook-Pro:~ gufei$ cd /personal/software/android_developtools/adt-bundle-mac-x86_64-20130522/sdk/tools
第二步:
gufeitekiMacBook-Pro:tools gufei$ ls
Jetemulator-x86monkeyrunner
NOTICE.txtemulator64-armproguard
adb_has_moved.txtemulator64-mipssource.properties
androidemulator64-x86sqlite3
antetc1toolsupport
appshierarchyviewersystrace
ddmshprof-convtemplates
dmtracedumpjobbtraceview
draw9patchlibuiautomatorviewer
emulatorlintzipalign
emulator-armmksdcard
emulator-mipsmonitor
第三步:
gufeitekiMacBook-Pro:tools gufei$ ./emulator -avd android_480_800
emulator: emulator window was out of view and was recentered
然后重新打开一个新的命令窗口
第四步:
gufeitekiMacBook-Pro:~ gufei$ cd /personal/software/android_developtools/adt-bundle-mac-x86_64-20130522/sdk/tools
gufeitekiMacBook-Pro:tools gufei$ ./monkeyrunner
Jython 2.5.3 (2.5:c56500f08d34+, Aug 13 2012, 14:54:35)
[Java HotSpot(TM) 64-Bit Server VM (Apple Inc.)] on java1.6.0_51
第五步:
from com.android.monkeyrunner import MonkeyRunner,MonkeyDevice,MonkeyImage
第六步:
android_480_800.installPackage("/personal/developer/android/project/UnionPay/Android/UPClient_3_0_lib/bin/UPClient_3_0_lib.apk")
ps:里面的5指等待5s,可以不写,代表永远等待,也可以自己自定义时间。
第七步:
android_480_800.installPackage("/personal/developer/android/project/UnionPay/Android/UPClient_3_0_lib/bin/UPClient_3_0_lib.apk")
安装成功后命令窗口打印出:True
第八步:
android_480_800.startActivity(component="com.unionpay/com.unionpay.client3.UPActivityWelcome")
观察模拟器是否已经打开该界面
第九步:(自己模拟点击坐标)
android_480_800.touch(386.0,399.0,android_480_800.DOWN_AND_UP)
android_480_800.touch(35.0,146.0,android_480_800.DOWN_AND_UP)
android_480_800.touch(5.0,609.0,android_480_800.DOWN_AND_UP)
android_480_800.touch(44.0,569.0,android_480_800.DOWN_AND_UP)
android_480_800.touch(-1.0,-1.0,android_480_800.DOWN_AND_UP)
android_480_800.touch(467.0,759.0,android_480_800.DOWN_AND_UP)
android_480_800.touch(457.0,726.0,android_480_800.DOWN_AND_UP)
android_480_800.touch(265.0,776.0,android_480_800.DOWN_AND_UP)
android_480_800.touch(271.0,787.0,android_480_800.DOWN_AND_UP)
android_480_800.touch(176.0,278.0,android_480_800.DOWN_AND_UP)
android_480_800.touch(187.0,257.0,android_480_800.DOWN_AND_UP)
result= android_480_800.takeSnapshot()
result.writeToFile("/Users/gufei/Downloads/MonkeyRunnerShoot.png")
print("OK!")
您可能感兴趣的文章:详解appium+python 启动一个app步骤Python脚本在Appium库上对移动应用实现自动化测试详解Android单元测试最佳实践android开机自启动APP及使用adb命令测试方法Android利用Espresso进行UI自动化测试的方法详解在Android打包中区分测试和正式环境浅析Android单元测试之对Activity的测试示例浅谈Android单元测试的作用以及简单示例Android和iOS 测试五个最好的开源自动化工具Android 中构建快速可靠的 UI 测试简单谈谈android studio 的单元测试Android Monkey压力测试详细介绍Ubuntu中为Android系统上实现内置C可执行程序测试Linux内核驱动程序Android App开发的自动化测试框架UI Automator使用教程Android测试中Appium的一些错误解决技巧