monkeyrunner入門之傳送郵件(四)
阿新 • • 發佈:2018-12-21
這裡我已Gmail為例,道理都是一樣的
device.touch裡面的數字是手機螢幕的座標,手機螢幕的座標這樣得知:
開啟設定–系統—開發者選項–指標座標
device.type模擬鍵盤輸入內容
提供可複製程式碼:
#coding:utf-8 #儲存檔案格式記得選擇utf-8,預設是ansi # 引入本程式所用到的模組 import time from com.android.monkeyrunner import MonkeyRunner, MonkeyDevice, MonkeyImage # 連線手機裝置 device = MonkeyRunner.waitForConnection() #開啟app, component="包名/activity名" #aapt dump badging apk包 可得到package: name 和 launchable-activity: name device.startActivity(component="com.google.android.gm/com.google.android.gm.ConversationListActivityGmail") # 暫停5秒(等app完全開啟) MonkeyRunner.sleep(5) #點選寫信 device.touch(947,1705,'DOWN_AND_UP') MonkeyRunner.sleep(2) #輸入收件人 device.type("
[email protected]") MonkeyRunner.sleep(2) #點選主題 device.touch(459,595,'DOWN_AND_UP') MonkeyRunner.sleep(2) #輸入主題 device.type("hello") MonkeyRunner.sleep(2) #點選內容 device.touch(487,871,'DOWN_AND_UP') MonkeyRunner.sleep(2) #編輯內容 device.type("IMissyou") MonkeyRunner.sleep(2) #點擊發送 device.touch(904,142,'DOWN_AND_UP') MonkeyRunner.sleep(2)