持续更新....
一个简单的例子,亲测可用
# Usage: monkeyrunner drag.py
# import the monkeyrunner modules
import sys
from com.android.monkeyrunner import MonkeyRunner,MonkeyDevice
# Prepare start and end with 10 steps in 1s
type = 'DOWN_AND_UP'
# PackageName and Activityname
package = 'com.android.androidui'
activity = '.MainActivity'
component = package+'/'+activity
# Connect device
device = MonkeyRunner.waitForConnection();
# press Country Drop Down
device.installPackage('./AndroidUI.apk');
# launch apk
device.startActivity(component)
print 'launch AndroidUI...'
# wait 1s
MonkeyRunner.sleep(5)
print 'wait compete...'
# touch country drop down
print 'start touch'
device.touch(200,380,type)
print 'complete touch_++++++++++++============================='
MonkeyRunner.sleep(5)
注意要点:
import sys -> 系统相关的信息模块
type = 'DOWN_AND_UP'也可以传空,MonkeyRunney源码中做了判断