[android]android自動化測試四之Monkey與MonkeyRunner
請大家用下面的範例來做Monkey test . 時間延遲設為300毫秒,基本上符合實際上的觸控間隔。各位只需要改變標記為黃色的部分。
adb shell monkey -p com.xxxx.news -s 12345 --pct-trackball 0 --pct-nav 0 --throttle 300 --pct-anyevent 4 --ignore-crashes 30000 &
adb shell monkey -p com.xxxx.systeminfo -s 12345 --pct-trackball 0 --pct-nav 0 --throttle 300 --pct-anyevent 4 --ignore-crashes 30000 &
adb shell monkey -p com.xxxx.todo -s 12345 --pct-trackball 0 --pct-nav 0 --throttle 300 --pct-anyevent 4 --ignore-crashes 30000
具體引數檢視
http://developer.android.com/guide/developing/tools/monkey.html
一個簡單的monkey指令碼:
# monkey
tap 100 180
type 123
tap 100 280
press DEL
press DEL
press DEL
press DEL
press DEL
press DEL
press DEL
press DEL
type -460.3
呼叫monkey指令碼
$ adb shell am start -n com.example.aatg.tc/.TemperatureConverterActivity
This is informed in the log by this line:
Starting: Intent { cmp=com.example.aatg.tc/.TemperatureConverterActivity }
Once the application has started you can send the events using the script and the
netcat utility:
$ nc localhost 1080 < monkey.txt
一個monkeyRunner的指令碼:monkey_playback.py
#! /usr/bin/env monkeyrunner
'''
Created on 2011-03-12
@author: diego
'''
import sys
# Imports the monkeyrunner modules used by this program
from com.android.monkeyrunner import MonkeyRunner, MonkeyDevice,
MonkeyImage
# Connects to the current device, returning a MonkeyDevice object
device = MonkeyRunner.waitForConnection()
if not device:
print >> sys.stderr, "Couldn't get connection"
sys.exit(1)
device.startActivity(component='com.example.aatg.tc/.
TemperatureConverterActivity')
MonkeyRunner.sleep(3.0)
device.type("123")
# Takes a screenshot
MonkeyRunner.sleep(3.0)
result = device.takeSnapshot()
# Writes the screenshot to a file
result.writeToFile('/tmp/device.png','png')
device.press('KEYCODE_BACK', 'DOWN_AND_UP')
更詳細的文章
http://www.cnblogs.com/yyangblog/archive/2011/03/10/1980086.html
adb shell monkey -p com.xxxx.news -s 12345 --pct-trackball 0 --pct-nav 0 --throttle 300 --pct-anyevent 4 --ignore-crashes 30000 &
adb shell monkey -p com.xxxx.systeminfo -s 12345 --pct-trackball 0 --pct-nav 0 --throttle 300 --pct-anyevent 4 --ignore-crashes 30000 &
adb shell monkey -p com.xxxx.todo -s 12345 --pct-trackball 0 --pct-nav 0 --throttle 300 --pct-anyevent 4 --ignore-crashes 30000
具體引數檢視
http://developer.android.com/guide/developing/tools/monkey.html
一個簡單的monkey指令碼:
# monkey
tap 100 180
type 123
tap 100 280
press DEL
press DEL
press DEL
press DEL
press DEL
press DEL
press DEL
press DEL
type -460.3
呼叫monkey指令碼
$ adb shell am start -n com.example.aatg.tc/.TemperatureConverterActivity
This is informed in the log by this line:
Starting: Intent { cmp=com.example.aatg.tc/.TemperatureConverterActivity }
Once the application has started you can send the events using the script and the
netcat utility:
$ nc localhost 1080 < monkey.txt
一個monkeyRunner的指令碼:monkey_playback.py
#! /usr/bin/env monkeyrunner
'''
Created on 2011-03-12
@author: diego
'''
import sys
# Imports the monkeyrunner modules used by this program
from com.android.monkeyrunner import MonkeyRunner, MonkeyDevice,
MonkeyImage
# Connects to the current device, returning a MonkeyDevice object
device = MonkeyRunner.waitForConnection()
if not device:
print >> sys.stderr, "Couldn't get connection"
sys.exit(1)
device.startActivity(component='com.example.aatg.tc/.
TemperatureConverterActivity')
MonkeyRunner.sleep(3.0)
device.type("123")
# Takes a screenshot
MonkeyRunner.sleep(3.0)
result = device.takeSnapshot()
# Writes the screenshot to a file
result.writeToFile('/tmp/device.png','png')
device.press('KEYCODE_BACK', 'DOWN_AND_UP')
更詳細的文章
http://www.cnblogs.com/yyangblog/archive/2011/03/10/1980086.html
相關文章
- [android]android自動化測試十三之monkeyRunner自動化框架Android框架
- Android 自動化測試之 MonkeyAndroid
- Android自動化測試之Monkeyrunner從零開始Android
- [android]Monkey自動化測試引數Android
- [android]android自動化測試十三之sciroccoAndroid
- [android]android自動化測試五之RobolectricAndroid
- [android]android自動化測試十四之dumpsys效能測試Android
- Android自動化測試入門(四)單元測試Android
- [android]android自動化測試Android
- [android]android自動化測試十五之junitRepoterAndroid
- [android]android自動化測試九之monkeyRecordAndroid
- [android]android自動化測試十之單元測試例項Android
- Junit測試Android自動化測試Android
- [Android]android自動化測試十六之calabash-androidAndroid
- Android 測試入門之---Monkey testAndroid
- [android]android自動化測試二之命令列建立AVDAndroid命令列
- [android]android自動化測試六之命令列編譯APKAndroid命令列編譯APK
- [android]android自動化測試十三之JavaMonkey跨APP操作AndroidJavaAPP
- [android]android自動化測試十二之程式碼控制截圖Android
- Android 談談自動化測試Android
- [android]android自動化測試七之動態AVD硬體引數Android
- Android自動化測試解決方案Android
- android monkey 測試方法實踐Android
- android自動化測試六之命令列編譯APKAndroid命令列編譯APK
- [android]android自動化測試三之設定AVD各項引數Android
- 自動化測試:Monkey工具實踐應用~
- android 5個自動化測試Ui框架AndroidUI框架
- [android]am自動化測試框架(原創)Android框架
- [android]android自動化測試十一之程式碼覆蓋率報告EMMAAndroid
- Android Monkey 壓力測試 介紹Android
- Android自動化測試工具實現簡述Android
- Android使用Espresso進行UI自動化測試AndroidEspressoUI
- Android 下的自動化測試工具總結Android
- Android UI 自動化測試實現過程AndroidUI
- Android穩定性測試-- Monkey原始碼分析Android原始碼
- Android命令Monkey壓力測試,詳解Android
- [android]android自動化測試八之讓你的AVD無法連線網路Android
- 自動化裝置測試與自動化測試的區別