monkeyrunner 錄製與回放

     一直認爲monkeyrunner的不方便之處就是不能錄製回放,要在手機內開啓座標去定位每一個控件的座標,很是不方便。今天居然發現monkeyrunner也有錄製回放的功能,欣喜若狂啊......學海無涯啊android

     1、新建一文件monkey_recorder.py,copy如下代碼express

  

#!/usr/bin/env monkeyrunner
# Copyright 2010, The Android Open Source Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.apache

from com.android.monkeyrunner import MonkeyRunner as mr
from com.android.monkeyrunner.recorder import MonkeyRecorder as recorderwindows

device = mr.waitForConnection()
recorder.start(device)app

 

2、在命令行中運行:less

monkeyrunner   文件夾路徑+\monkey_recorder.py工具

 

3、運行後的便會出現圖形化界面,錄製完以後能夠保存腳本。在使用過程當中發現錄製腳本的工具並非很強大,有些操做沒法錄製,好比長按HOME鍵的操做,返回鍵的操做等等。ui

4、回放:this

     運行保存的腳本,而後你就看到模擬器進行你剛纔同樣的操做:命令行

     monkeyrunner monkey_playback.py monkey_test.mr

     注:monkey_recorder.py,monkey_test.mr,monkey_playback.py都應放在..\android-sdk-windows\tools目錄下。

相關文章
相關標籤/搜索