??????????????о???????????????????????????????ID???в??????????????????????????????

????1??????????? oolshierarchyviewer.bat???????????????ó????ID??

????????hierarchyviewer.bat??????裺

??????1????????????????????????ID????????檔?????google?????????????????????hierarchyviewer.bat??????????????activity????????????е?????????????????????????

??????2?????Load View Hierarchy????????????????????????????????????ID?????

????????????????????????????????????????λ???????????????????????????????Щ???????????????????С?

????2?????EasyMonkeyDevice???By??????????ID??

?????Щ????????д?????£?

??????1????????IDд????

????easy_device.type(By.id('id/name_text)??'zhangsan')

??????2???????/???/?????IDд????

????easy_device.touch(By.id('id/login_button')??MonkeyDevice.DOWN_AND_UP)

??????3????????ID????????????????ò????ж?λ

????easy_device.touch(By.id('id/parent_button')??MonkeyDevice.DOWN_AND_UP??By.id('id/current_button')??MonkeyDevice.DOWN_AND_UP)

???????ID???м????????????calculator.py??

from com.android.monkeyrunner import MonkeyRunner??MonkeyDevice
from com.android.monkeyrunner.easy import EasyMonkeyDevice
from com.android.monkeyrunner.easy import By
from com.android.chimpchat.hierarchyviewer import HierarchyViewer
from com.android.hierarchyviewerlib.device import ViewNode
device = MonkeyRunner.waitForConnection()
package = 'com.android.calculator2'
activity = 'com.android.calculator2.Calculator'
runComponent = package + '/' + activity
device.startActivity(component=runComponent)
MonkeyRunner.sleep(3.0)
easy_device = EasyMonkeyDevice(device)  #init easymonkeydevice object must start activity at first.Because the init method
will getHierarchyViewer()??
easy_device.touch(By.id('id/digit7')??MonkeyDevice.DOWN_AND_UP)
easy_device.touch(By.id('id/mul')??MonkeyDevice.DOWN_AND_UP)
easy_device.touch(By.id('id/digit8')??MonkeyDevice.DOWN_AND_UP)
easy_device.touch(By.id('id/equal')??MonkeyDevice.DOWN_AND_UP)
MonkeyRunner.sleep(1.0)
pic = device.takeSnapshot()
pic.writeToFile('D??\monkeyrunner\result.png'??'png')
print 'test finished??'

????3???????????????7*8=56??????result.png??monkeyrunner   calculator.py

??????ID???в?????????????·??????????б?????????????????????????ID????????????????ID??????