仍然以瀏覽器搜素為例
1、編寫.py指令碼
#!/usr/bin/python
#coding:utf-8
from com.android.monkeyrunner import MonkeyRunner, MonkeyDevice,MonkeyImage
# 連線裝置,檢視裝置名稱adb devices
device = MonkeyRunner.waitForConnection(3,"emulator-5554")
# 啟動APP
device.startActivity("mixiaba.com.Browser/mixiaba.com.Browser.ui.activities.MainActivityGroup")
MonkeyRunner.sleep(2)
# 點選輸入框
device.touch(100,700,"DOWN_AND_UP")
MonkeyRunner.sleep(1)
# 輸入查詢詞
device.type('test')
MonkeyRunner.sleep(1)
# 點選Enter鍵
#device.press('KEYCODE_ENTER',"DOWN_AND_UP")
#MonkeyRunner.sleep(1)
# 點選搜尋按鈕
device.touch(900,700,"DOWN_AND_UP")
MonkeyRunner.sleep(6)
# 截圖
image = device.takeSnapshot()
image.writeToFile('D:/monkeyProject/test/123.png','png')
2、執行指令碼
3、可以看到對應資料夾生成了截圖