MonkeyRunner_MonkeyRunner API简单使用帮助.(附示例)
2012-08-06 15:29
99 查看
本人写脚本的时候,经常忘记API使用方法,现列举常用的API并附上示例,希望在大家写脚本的时候有帮助!如果有问题,请留言给我,谢谢!
1. #导入模块;
from com.android.monkeyrunner import MonkeyRunner, MonkeyDevice, MonkeyImage
2. #连接当前设备,并返回一个MonkeyDevice对象;
device = MonkeyRunner.waitForConnection()
if not device:
print "Please connect a device to start!"
else:
print "Start "
3. #安装Android包,注意,此方法返回的返回值为boolean,由此可以判断安装过程是否正常 ;
device.installPackage('myproject/bin/MyApplication.apk')
4. #启动一个Activity;
device.startActivity(component='com.android.htccontacts/com.android.htccontacts.ContactsTabActivity')
5. #截图;
result = device.takeSnapshot()
result.writeToFile('C:\\Users\\Martin\\Desktop\\test.png','png')
6. #时延(秒);
MonkeyRunner.sleep(3)
7. #滑动屏幕;
for i in range(1,70):
device.drag((250,850),(250,110),0.1,10)
for i in range(1,70):
device.drag((250,110),(250,850),0.1,10)
MonkeyRunner.sleep(1)
8. #触击屏幕;
device.touch(507,72,"DOWN_AND_UP")
9. #执行adb shell命令;
device.shell("input text goup01")
1. #导入模块;
from com.android.monkeyrunner import MonkeyRunner, MonkeyDevice, MonkeyImage
2. #连接当前设备,并返回一个MonkeyDevice对象;
device = MonkeyRunner.waitForConnection()
if not device:
print "Please connect a device to start!"
else:
print "Start "
3. #安装Android包,注意,此方法返回的返回值为boolean,由此可以判断安装过程是否正常 ;
device.installPackage('myproject/bin/MyApplication.apk')
4. #启动一个Activity;
device.startActivity(component='com.android.htccontacts/com.android.htccontacts.ContactsTabActivity')
5. #截图;
result = device.takeSnapshot()
result.writeToFile('C:\\Users\\Martin\\Desktop\\test.png','png')
6. #时延(秒);
MonkeyRunner.sleep(3)
7. #滑动屏幕;
for i in range(1,70):
device.drag((250,850),(250,110),0.1,10)
for i in range(1,70):
device.drag((250,110),(250,850),0.1,10)
MonkeyRunner.sleep(1)
8. #触击屏幕;
device.touch(507,72,"DOWN_AND_UP")
9. #执行adb shell命令;
device.shell("input text goup01")
相关文章推荐
- MonkeyRunner_使用MonkeyRunner对Calculator进行简单的压力测试(脚本示例)
- Hbase使用commons-pool简单对象池示例
- C++ Builder 中StringDrid简单使用示例
- Unity3d 反编译破解游戏 简单示例 (使用ildasm反编译DLL修改然后重新编译DLL)
- ArrayList、TreeSet、TreeMap、HashSet和HashMap的简单使用示例
- 使用tensorflow实现全连接神经网络的简单示例,含源码
- GCM Google官方示例的简单介绍和使用
- ibeacon的使用和应用场景简单示例
- 使用vue实现简单键盘的示例(支持移动端和pc端)
- Lucene.NET使用入门(二)【简单的搜索网站示例】
- Docker应用示例2--使用Docker创建简单集群服务
- springMVC和Shiro框架整合使用简单示例
- Redis和Jedis简单使用示例
- springMVC和Shiro框架整合使用简单示例 【转】
- 在c#多线程使用IOCP(完成端口)的简单示例
- ICE简单介绍及使用示例
- java线程使用示例——最简单的线程
- 在python中使用c语言扩展模块的简单示例
- ubuntu下使用golang、qml与ubuntu sdk开发桌面应用 (简单示例)