python adb 自動化測試--20200114檔

20200114測試記錄

--來自:https://mp.weixin.qq.com/s/m5NVrayleQWztpJNbZ7mEA

工具:

  • window10
  • vivo x20  

軟件:

 

測試代碼:

import os
import time

def execute(cmd):
    adbstr = "adb shell {}".format(cmd)
    print(adbstr)
    os.system(adbstr)

if __name__ == '__main__':
    #打開騰訊視頻
    execute("am start -n com.tencent.qqlive/.ona.activity.SplashHomeActivity")
    time.sleep(5)
    #跳過廣告
    #execute("input tap 965 67")
    time.sleep(1*5)
    #點擊搜索框
    execute("input tap 428 280")
    time.sleep(0.5)
    execute("input tap 601 157")
    time.sleep(0.5)
    #輸入動漫名
    # execute("input text 斗羅大陸")
    #切換手機輸入法(爲解決中文亂碼下載的adb輸入法
    # https://github.com/senzhk/ADBKeyBoard/raw/master/ADBKeyboard.apk
    # https://blog.csdn.net/qq_36350532/article/details/81707021
    # https://blog.csdn.net/weixin_39246787/article/details/80564615
    # )
    #切換爲adb輸入法
    execute("ime set com.android.adbkeyboard/.AdbIME")
    time.sleep(2)
    execute("am broadcast -a ADB_INPUT_TEXT --es msg 斗羅大陸")
    #切換爲原來的輸入法
    execute("ime set com.sohu.inputmethod.sogou.vivo/.SogouIME")
    time.sleep(3)

    #點擊搜索
    execute("input tap 994 148")
    time.sleep(0.5)
    #選集
    execute("input tap 453 1097")
    time.sleep(0.5)
    execute("input swipe 559 2000 559 630")
    time.sleep(1)
    # 最後一集
    execute("input tap 130 1921")
    time.sleep(0.5)
    execute("input keyevent 25")
    time.sleep(0.5)
    #從頭開始播放
    #execute("input tap 352 603")
    print("開始看劇吧")

問題:

      中文輸入亂碼-沒有效果[adb shell input text 中文]:

解決:

     使用ADBKeyBoard輸入法即可解決

     ADBKeyBoard下載

   具體使用方法:https://blog.csdn.net/slimboy123/article/details/54140029  https://github.com/senzhk/ADBKeyBoard

   adb shell 切換輸入法:

  • 安裝   ADBKeyBoard輸入法   (手動設置爲默認的-或者使用adb set)
  • 手機先連接adb
  • 輸入:[  adb shell ime list ] 獲取到當前設備上的所有輸入法--裏面有輸入法的全包路徑
  • [adb shell ime set 全包路徑] 例如:[adb shell ime set com.android.inputmethod.pinyin/.PinyinIME]
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章