Android?????????:MonkeyRunner????ID
???????????? ???????[ 2013/7/8 15:28:13 ] ????????
??????????????о???????????????????????????????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??????
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11