android 自動化測試案例之 MonkeyScript

來源:互聯網
上載者:User

標籤:detail   檔案名稱   bat   auto   start   roi   tools   sdcard   bsp   

#檔案名稱 MonkeyScript.mks
#功能: 使用monkey script測試app,此案例是測試搜尋功能(輸入關鍵字,然後點擊搜尋按鈕)
#參考:http://blog.csdn.net/superloveboy/article/details/48469393
#http://yiweifen.com/html/news/WaiYu/13792.html
#http://androidxref.com/5.1.1_r6/xref/development/cmds/monkey/src/com/android/commands/monkey/MonkeySourceScript.java
#android.view.KeyEvent.java

#可以使用 Android/sdk/tools/uiautomatorviewer.bat 擷取座標點

#執行方式 拷貝檔案到手機上 比如/sdcard/00/MonkeyScript.mks,運行"adb shell monkey -f /sdcard/00/MonkeyScript.mks 10"(不包括引號)
#-f後面為指令檔的路徑,最後一個數字表示指令碼執行的次數

#下面的這4行是固定值,不用修改,表示指令碼的開頭
type = user
count = 10
speed = 1.0
start data >>

#啟動activity
LaunchActivity(com.iotlife.action,com.iotlife.action.activity.SearchDetailActivity)
#等待ms時間
UserWait(200)

#DispatchPointer為點擊某個座標點,只關注第3,4,5個參數
#第三個參數為事件類型(0為down,1為up),第4,5參數為座標點x,y
#也可以用 Tap(1000,100) 代替
DispatchPointer(10,10,0,400,100,0,0,0,0,0,0,0);
DispatchPointer(10,10,1,400,100,0,0,0,0,0,0,0);
UserWait(300)

#輸入一個字串
DispatchString(test)
#輸入一個斷行符號鍵
DispatchPress(KEYCODE_ENTER)
UserWait(300)


#DispatchPointer(10,10,0,1000,100,0,0,0,0,0,0,0);
#DispatchPointer(10,10,1,1000,100,0,0,0,0,0,0,0);
UserWait(300)

 

android 自動化測試案例之 MonkeyScript

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.