wrapEasyMonkey 2.0 released
2.0 version is released . copyright(c) whoistester.com
new 新特性:
1. don’t need set the env vars anymore
不需要再设置wrapeasymonkey的环境变量了
2. just put the lib into the android sdk tools lib directory
只需要将wrapeasymonkey的lib 放到 android sdk 的tools文件夹里的lib目录里,就可以使用,简单。
3. write the test case with python code , and monkeyrunner run it.
写测试用例代码,并用monkeyrunner 执行该case
Pre-use: 前提:
1. you have the android sdk installed.
你需要android sdk 安装
2. download the wrapEasyMonkey 2.0 from sourceforge
下载wrapeasymonkey 2.0 并放到正确的lib目录下
Install the lib 安装lib:
1. unzip the downloaded file and extract the wrapeasymonkey.jar.
解压,并拿到wrapeasymonkey.jar
2. mv the jar to the lib directory of the android sdk tools dir.
将jar移动到 android sdk 的tools文件夹里的lib目录里
How to use: 如何使用
1. write the python code folow the examples , and monkeyrunner it.
It’s easy to test the android.
Known isues: 已知问题
1. couldn’t simultaneously run multi test process on multi devices. 经过试验, 同一个脚本不能同时在多个设备上运行. 该问题经分析应为monkeyrunner及android底层问题. 当同时执行时,既传入的deviceid 不同,但会发现发送的event会串. 既发给a设备的key动作,有时会串到b设备.
2. couldn’t locate the coordinate of the dialog button , you should use the direction press to chose ok or cancel and context menu instead . 系统对话框的坐标不能通过id进行定位, 需要通过发送方向键,来定位并进行触摸touch.
testcase examples: 测试用例示例代码:
''' Copyright (C) 2012 @author: nighteblis%hotmail.com (% to @) ''' #code begain here from com.whoistester.android.testimport import os,sys,re,string,locale,ViewClient,wrapEasyMonkey,MonkeyDevice,MonkeyRunner,EasyMonkeyDevice,By package = 'com.whoistester.android' activity = '.account.login' component = package + "/" + activity deviceId=sys.argv[1] ###### If you know your deviceid , please give a constant string mydevice = wrapEasyMonkey(deviceId) mydevice.startActivity(component) mydevice.caseManager.setResultPath('/test/testresult') ## the location where you want the result to be in mydevice.caseManager.testSetup() for yy in range(1): '''''''''''''''''''''''''' #case 1 '''''''''''''''''''''''''' mydevice.caseManager.caseStart('login') mydevice.clearTextById('id/theaccount') mydevice.caseManager.saveCaseStatus('') # take a snap shot mydevice.type('nighteblis') mydevice.press('KEYCODE_AT',mydevice.DOWN_AND_UP) mydevice.type('hotmail.com') mydevice.clearTextById('id/thepassword') mydevice.type('mypassword') mydevice.press('KEYCODE_BACK',mydevice.DOWN_AND_UP) mydevice.caseManager.saveCaseStatus('') mydevice.touchViewById('id/login_button',mydevice.DOWN_AND_UP) mydevice.caseManager.assertText('id/setpassword','set your password') mydevice.caseManager.saveCaseStatus('') mydevice.caseManager.caseEnd()
此篇文章已被阅读6134 次
你好, 我从github上用zip方式下载了你的源码,然后改名为wrapeasymonkey.jar
在使用的时候, 我用 from com.whoistester.android.testimport import os,sys,re,string,locale,ViewClient,wrapEasyMonkey,MonkeyDevice,MonkeyRunner,EasyMonkeyDevice,By
但提示错误:No module named whoistester
请问怎么解决, 谢谢
http://sourceforge.net/projects/wrapeasymonkey/files/latest/download
请从sourceforge 下载试下, 解压后有个jar。
github上的代码出现问题的原因:
1. github的zip打包不清楚是否有其他非预期的行为。 比如包内多嵌套一层文件夹等,可以解压后查看确认。
2. github的代码后期上传后,没有再经过实际的测试。
D:\Android\android-sdk\tools>monkeyrunner login.py
__pyclasspath__/com/whoistester/android/viewclient.py:9: RuntimeWarning: Unable
to determine _shell_command for underlying os: nt
160510 10:17:31.875:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions
] Script terminated due to an exception
160510 10:17:31.875:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions
]Traceback (most recent call last):
File “D:\Android\android-sdk\tools\login.py”, line 12, in
from com.whoistester.android.testimport import os,sys,re,string,locale,wrapE
asyMonkey
File “__pyclasspath__/com/whoistester/android/testimport.py”, line 22, in
File “__pyclasspath__/com/whoistester/android/wrapEasyMonkey.py”, line 32, in
ImportError: cannot import name ViewNode
是怎么解决呢
不建议再使用此工具。 建议使用uiautomator 或者 apium 。
看样子zyj是想用python开发, 所以可以看下 https://github.com/xiaocong/uiautomator uiautomator的python wraper。 或者用apium,支持python。
very good!