Menu

wrapEasyMonkey howto入门教程2.0

whoistester

2.0 version is released . copyright(c) whoistester.com

http://lihao.cf/wrapeasymonkey-2-0-released/

new:
1. don't need set the env vars anymore
2. just put the lib into the android sdk tools lib directory
3. write the test case python code , and monkeyrunner run it.

Pre-use:
1. you have the android sdk installed.
2. download the wrapEasyMonkey 2.0 from sourceforge

More blogs access http://lihao.cf/category/my-work/wrapeasydevice/

Install the lib:
1. unzip the downloaded file and extract the wrapeasymonkey.jar.
2. mv the jar to the lib directory of the android sdk tools dir.

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 simultaniuosly run multi test process on multi devices.
2. couldn't locate the location of the dialog button , you should use the direction press to chose ok or cancel and context menu instead .

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()



Related

Wiki: Home