2014-01-09 57 views
0

嗨,我是一个新的使用猴子脚本。 任何人都可以告诉我我要做什么来测试whol应用程序。所有的点击,特别是如何拧出日志文件。我到目前为止尝试过代码,但它无法测试我的整个应用程序。我在我的应用程序中有两个活动,一个是主要LEt假设A和另一个是设置屏幕B.任何人都可以告诉我脚本和我应该在我的xxx.py中测试 整个功能的命令。我到目前为止所尝试的是。Android monekyrunner测试

!在/ usr/bin中/ env的monkeyrunner

from com.android.monkeyrunner import MonkeyRunner, MonkeyDevice 
from random import randint 

print "get device" 
device = MonkeyRunner.waitForConnection() 
package = 'xx.xxxx.xxxx' 
activity = 'xxx.exampleactivity 
runComponent = package + '/' + activity 
device.startActivity(component=runComponent) 

#use commands like device.touch and device.drag to simulate a navigation and open my activity 

#with your activity opened start your monkey test 
print "start monkey test" 
for i in range(1, 1000): 
    #here i go emulate only simple touchs, but i can emulate swiper keyevents and more... :D 
    device.touch(randint(0, 1000), randint(0, 800), 'DOWN_AND_UP') 

print "end monkey test" 

回答

0

如果你的目的是要产生的随机事件,你必须使用的工具是UI/Application Exerciser Monkey。类似的名字,但功能不同。

+0

我上面的脚本有什么错?它是不完整的? 我想用monkey runner来测试每个n的每个功能。请告诉我我的这个脚本中缺少什么东西?或者我必须添加更多关键事件或触摸事件? –

+0

你正在发送随机事件,这就是'猴子'的用途。为什么重新发明轮子? –