Monkeyrunner 通过id点击屏幕, 发生的问题?
继续提问:背景: 通过monkeyrunner中touch方法,按照id的方式去点击屏幕, 代码如下
代码行1: device = MonkeyRunner.waitForConnection()
代码行2: # Use the EasyMonkey API, all methods on device are available in easy_device.
代码行3: easy_device = EasyMonkeyDevice(device)
代码行4:print easy_device # <com.android.monkeyrunner.easy.EasyMonkeyDevice object at 0x1>
代码行5:easy_device.touch(By.id('id/prempindao'), 'DOWN_AND_UP')
问题: 代码行5 为什么不能点击呢????????
解决过程:
hierarchy_viewer = device.getHierarchyViewer()
view_node = hierarchy_viewer.findViewById('id/prempindao')
text = view_node.namedProperties.get('mID').toString()
print text # 这里是可以打印出来的,也就是说能够找到id
求高手指教啊??????????????????????
--------------------编程问答-------------------- easy_device.touch(By.id('id/prempindao',MonkeyDevice.DOWN_AND_UP) --------------------编程问答-------------------- 为什么我运行时提示:importerror:no module named easy,望楼主解答下。。。 --------------------编程问答--------------------
需要引入包,命令如下:
from com.android.monkeyrunner.easy import EasyMonkeyDevice,By --------------------编程问答--------------------
补充:移动开发 , Android