Android monekyrunner测试

时间:2014-01-09 12:23:44

标签: monkeyrunner

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

! / 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"

1 个答案:

答案 0 :(得分:0)

如果您打算生成随机事件,则必须使用的工具是UI/Application Exerciser Monkey。名称相似但功能不同。