使用ADB命令寫Android自動化測試腳本


使用腳本來執行測試的特點:

  ●書寫方便

  ●基本上可以實現90%以上的功能性覆蓋

  ●測試結果需要通過自己觀察整個過程和日志文件來得出的

  ●有些外部的動作,腳本是無法實現的,比如錄入指紋

  ●只適配特定尺寸的設備

  ●沒法對內容進行校驗

  ●執行命令間隔時間要把控好

 

常用命令

  1、打電話

    adb   shell   am   start   -a   android.intent.action.CALL   -d   tel:10086

  2、打開QQ

    adb   shell   am   start   -a   android.intent.action.MAIN   -c   android.intent.category.LAUNCHER

  3、打開微信

    adb   shell   am   start   com.tencent.mm/com.tencent.mm.ui.LauncherUI

  4、打開支付寶

    adb   shell   am   start   com.eg.android.AlipayGphone/.AlipayLogin

  5、殺死支付寶

    adb   shell   am   force-stop   com.eg.android.AlipayGphone

  6、關閉QQ

    adb   shell   am   force-stop   com.tencent.mobileqq

  7、點擊事件

    adb   shell   input   tap   500   500

  8、home鍵

    adb   shell   input   keyevent   3

  9、返回鍵

    adb   shell   input   keyevent   4

  10、截圖(保存到sdcard)

    adb   shell   /system/bin/screencap   -p   /sdcard/screenshot.png

  11、錄屏

    adb   shell   screenrecord   /sdcard/test.mp4

    adb   pull   /sdcard/test.mp4   /Users/dhht/Desktop/test.mp4

  12、亮屏

    adb   shell   input   keyevent   26

  13、上下滑動

    adb   shell   input   swipe   700   2000   700   1000

  14、左右滑動

    adb   shell   input   swipe   100   1000   1000   1000

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM