1.alert 警告框
void alert(string message,string title,string okTitle)
eg: 0814.py
from com.android.monkeyrunner import MonkeyRunner
MonkeyRunner.alert(“hello”, “this is title”, “OK”)
在命令框输入:monkeyrunner E:\projects\0814.py
2.waitForConnection 等待设备连接,需指明设备
waitForConnection(float timeout,string deviceid)
3.drag
drag(tuple start,tuple end,float duration,integer steps)
起点位置,终点位置,手势持续时间,插值点步数,默认10
4.press
press(string keycode,dictionary type)
KEYCODE_ENTER
keycode:Down,Up,DOWN_AND_UP
5.startActivity 启动应用
startActivity(package+’/ '+activity) 根据XML配置文件
6.touch 点击
touch(integer x,integer y,integer type)
type:Down,Up,DOWN_AND_UP
7.type 输入
type(string message)
8.takeSnapshot 截屏
MonkeyImage takeSnapshot()
9.sameAs
boolean sameAs(MonkeyImage other,float percent)
10.writetoFile 保存图像文件
void writetoFile(string path,string format)
下一篇同样做一个小小的实践。用monkeyrunner来实践之前monkeyscript的例子。