當前位置:首頁 » 網頁前端 » idea寫monkey腳本
擴展閱讀
webinf下怎麼引入js 2023-08-31 21:54:13
堡壘機怎麼打開web 2023-08-31 21:54:11

idea寫monkey腳本

發布時間: 2022-07-12 05:39:42

『壹』 monkeyrunner 怎麼錄制腳本

1. 保證有android sdk, sdk的tools文件夾里有一個monkeyrunner.bat.
2.建文件:monkey_recorder.py
#!/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 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.
from com.android.monkeyrunner import MonkeyRunner as mr
from com.android.monkeyrunner.recorder import MonkeyRecorder as recorder
device = mr.waitForConnection()
recorder.start(device)
3.建文件:monkey_playback.py
#!/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 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.
import sys
from com.android.monkeyrunner import MonkeyRunner
# The format of the file we are parsing is very carfeully constructed.
# Each line corresponds to a single command. The line is split into 2
# parts with a | character. Text to the left of the pipe denotes
# which command to run. The text to the right of the pipe is a python
# dictionary (it can be evaled into existence) that specifies the
# arguments for the command. In most cases, this directly maps to the
# keyword argument dictionary that could be passed to the underlying
# command.
# Lookup table to map command strings to functions that implement that
# command.
CMD_MAP = {
'TOUCH': lambda dev, arg: dev.touch(**arg),
'DRAG': lambda dev, arg: dev.drag(**arg),
'PRESS': lambda dev, arg: dev.press(**arg),
'TYPE': lambda dev, arg: dev.type(**arg),
'WAIT': lambda dev, arg: MonkeyRunner.sleep(**arg)
}
# Process a single file for the specified device.
def process_file(fp, device):
for line in fp:
(cmd, rest) = line.split('|')
try:
# Parse the pydict
rest = eval(rest)
except:
print 'unable to parse options'
continue
if cmd not in CMD_MAP:
print 'unknown command: ' + cmd
continue
CMD_MAP[cmd](device, rest)
def main():
file = sys.argv[1]
fp = open(file, 'r')
device = MonkeyRunner.waitForConnection()
process_file(fp, device)
fp.close();
if __name__ == '__main__':
main()
4. cd到monkeyrunner.bat 的目錄里, 運行 monkeyrunner ..\..\monkey_recorder.py (絕對路徑)
5.點擊屏幕即會生成坐標,還有按button,輸入文本,滑動等事件 ,錄制完畢後選擇Export Actions就將腳本保存下來了,保存的時候不需要後綴名。(也可加後綴名:*.mr)
6.回放:
cd到monkeyrunner.bat 的目錄里, 運行 monkeyrunner ..\..\monkey_playback.py ..\..\第5步中保存的文件名(均為絕對路徑)

『貳』 monkey測試怎麼執行script腳本

一、利用fontMonkey測試工具包 1、下載FoneMonkey.zip文件並解壓 2、用xcode打開工程目錄 3、添加一個測試用的target並重命名: 4、選取剛才創建的target並將解壓好的FontMonkey倒入工程目錄 也可以直接拖入到文件目錄:倒入時確保你的target為...

『叄』 monkeyrunner 編寫python腳本運行時遇到的幾個問題

  1. 你需要添加一句轉換目錄: chdir(%ANDROID_HOME/sdk/tools)

  2. 添加Except異常到文件

『肆』 請問用python寫monkeyrunner的腳本,在哪裡可以調試腳本

pycharm 是一個很好的調試環境

『伍』 ios中monkey測試腳本怎麼寫

一、利用fontMonkey測試工具包

1、下載FoneMonkey.zip文件並解壓
2、用xcode打開工程目錄
3、添加一個測試用的target並重命名:
4、選取剛才創建的target並將解壓好的FontMonkey倒入工程目錄 也可以直接拖入到文件目錄:倒入時確保你的target為剛才添加的
5、此時在你的框架中會默認添加兩個文件

libFoneMonkey.5.4a.beta.a

libFoneMonkeyOCUnit.5.4a.beta.a
這兩個文件在FoneMonkey的lib文件夾中,如果框架管理中沒有,則可以直接拖過去;

然後再添加幾個框架文件(默認有三個),libxml2.dylib、SenTestingKit.framework、QuartzCore.framework

6、修改工程的配置文件 Buile Seting->Linking->Other Linker Flags

添加選項 -all_load

7、開始編譯程序 選擇測試target以及模擬器(真機器還沒試驗),運行

二在Instrument中編寫腳本進行測試(不能錄制)
1、打開Instruments工具 一般路徑:/Developer/Applications/instrument
2、選擇Automation
3、添加測試腳本(如果有現成的,可以導入)
4、編寫腳本

給出測試幾個按鈕點擊的腳本

var target = UIATarget.localTarget(); //變數用來表示這是一個測試系統
var application = target.frontMostApp(); //確定要測試的程序
var window = application.mainWindow(); //確定要冊書的窗口
window.logElementTree(); //獲取要測試界面的所有元素
var bt=window.buttons()[2];

if(bt.isValid()){
bt.tap();
}
else{
UIAlogger.logMessage("some error show!");
}

5、倒入程序的xx.app 包
6、點擊Record將會直接通過腳本去點擊程序中的一個按鈕

『陸』 你好 關於monkeyrunner測試,如何寫一個bat文件執行多個測試腳本

請用start 否則P處理會等待第一條執行結束後才會執行第二條。


start "" monkeyrunner D:\Python\sanity\test1.py
start "" monkeyrunner D:\Python\sanity\test2.py
start "" monkeyrunner D:\Python\sanity\test3.py

『柒』 如何利用java語言編寫monkeyrunner功能測試腳本

請用start 否則P處理會等待第一條執行結束後才會執行第二條。

start "" monkeyrunner D:\Python\sanity\test1.py
start "" monkeyrunner D:\Python\sanity\test2.py
start "" monkeyrunner D:\Python\sanity\test3.py

『捌』 如何編寫monkey腳本

s MyFrame(wx.Frame):
delayDefault = "2"
seedDefault = ""
executionFrequencyDefault = ""
logDir = "./"
def __init__(self):

wx.Frame.__init__(self, None, -1, "My Frame", size=(500, 800))
panel = wx.Panel(self, -1)

xPos = 10
xPos1 = 180
yPos = 12
yDelta = 40
excuteMode = ["忽略程序崩潰",
"忽略程序無響應",
"忽略安全異常",
"出錯中斷程序",
"本地代碼導致的崩潰",
"默認"
]

logMode = ["簡單","普通","詳細"]
executionModeDefault = excuteMode[0]

menuBar = wx.MenuBar()
menu1 = wx.Menu("")
menuBar.Append(menu1, "File")
self.SetMenuBar(menuBar)

wx.StaticText(panel, -1, "種子數:", pos=(xPos, yPos))
self.seedCtrl = wx.TextCtrl(panel, -1, "", pos=(xPos1, yPos))
self.seedCtrl.Bind(wx.EVT_KILL_FOCUS, self.OnAction)
self.seedCtrl.SetFocus()

wx.StaticText(panel, -1, "執行次數:", pos=(xPos, yPos+yDelta))
self.excuteNumCtrl = wx.TextCtrl(panel, -1, "", pos=(xPos1, yPos+yDelta))