badboy中文手冊

BadBoy 手冊

badboy簡介

Badboy監控internet explorer的活動,提供錄製/回放功能.

錄製功能:badboy窗口的頂部顯示當前是否處於錄製狀態,如果點擊play按鈕,badboy自動關閉錄製功能,等到play結束後,可以點擊recording按鈕,繼續錄製腳本.

     Remark:必須等到上一步的request處理完畢後,才能點擊發送下一個request,否則下一個request會作爲第一個request的子frame.

 

基本操作

1 創建 suites,tests以及steps

測試與網站的交互過程,可以在邏輯上劃分爲幾個步驟.例如第一個步驟爲登陸雅虎郵箱,第二步爲瀏覽收件箱,第三步爲發送郵件.每一個步驟可以包含一到多次的網站交互動作.badBoy中點擊new step創建新的步驟. .同理,可以創建suites 以及tests.

     Badboy回放時,一次執行一個step,每執行完一個step,會顯示執行結果,用戶必須再次點擊play按鈕後,執行下一個step.

 

2 自動化測試腳本

如果不修改腳本,簡單的錄製回放並不能滿足複雜網站的測試.

複雜網站往往有下面一些測試場景:

A 頁面參數唯一性要求,例如:註冊頁面,需要對用戶的註冊名進行唯一性校驗.

B 測試的server地址不同.

Badboy提供了易用的參數修改方法,僅僅需要雙擊request或者參數,在彈出窗口內修改.同時badboy提供search&replacing功能來修改腳本中的參數值.

 

Remark:建議選擇linking variables,同一個參數,往往腳本會發送多次,選擇linking variables,badboy會查找所有的與參數有關的值.並統一替換.

 

特點與技術

1 錄製模式

   Badboy提供兩種錄製模式: request 模式(默認模式) navigation 模式.點擊下圖N,切換模式.

Request模式具有如下優點:如果測試的網頁模版修改了,不影響腳本的回放.如果需要badboy導出腳本到jmeter進行性能測試,必須選擇request模式.同時request模式的缺點如下:request模式需要添加大量的斷言來檢查頁面上的item.

Navigation模式將會記錄網站交互過程中browser中的元素的點擊動作.當回放navigation模式腳本時候,不但回放http request,同時badboy會模擬brower中點擊動作.navigation模式的缺點是 :無法使用navigation腳本進行性能測試,因爲性能測試引擎運行時候不顯示任何用戶界面,所以無法執行navigation中模擬點擊等動作.

總結:選擇navigation模式還是request模式,取決於測試的目的,如果僅僅要求測試功能而不關心界面,request模式無疑爲首選.

 

2 navigation模式

Navigation錄製browser的三種元素如下:

1 鏈接點擊

2 按鈕點擊

3 其他點擊,例如引發javaScript的操作.

3 表單提交

表單提交是頁面中非常重要的部分,有下面一些案例需要注意:

1 如果頁面表單中某些參數是依賴於某些參數的輸入,比如field B javascript根據field A的輸入值計算,使用request模式將無法錄製正確的參數.

 

2 request模式下,表單中的所有參數都將發送.包括一些預定義的元素.

 

自動錄製form的方法:點擊form中某一field,"Ctrl-Alt-f"錄製form,如果每次提交的form名字不同的話,可以使用正則表達式來表示: logonForm[0-9]{4}

 

 

4 斷言

斷言是自動化檢測的實現手段,badboy提供了兩種斷言:

1 content 檢查

檢查頁面中是否包含指定的text.斷言可以使用正則表達式,比如要檢查一個正確登陸的例子,需要檢查”welcome [A-z0-9]*/.”

問題:例子,比如”tree frog”browser中顯示,html中顯示爲"tree frog",因爲badboy測試實際的html source,因此將找不到這個斷言.避免這個問題的方法是在page中高亮顯示text,並使用easy assertion button.如果使用複雜斷言,需要精確匹配html source中的text.

5 截屏

當測試失敗時候,截屏是最有效的方法與開發人員溝通.在斷言的屬性欄中,選擇失敗是截屏.badboy會截取失敗案例的browser.

 

6 timeout

可以爲每個request設置timeout時間,右鍵點擊à選擇屬性à選擇play標籤,設置timeout時間.

 

7 彈出框

使用斷言檢查彈出框,郵件選擇斷言,打開"Check against Message Boxes"選項.

 

 

8 Badboyjmeter使用注意事項:

1 導出jmeter腳本的時候,jscript不被導出,因爲jmeter無內遷browser,jscript元素無法執行.

2 data sources不被導出.

 

9 快捷方式

快捷方式如下:

F2 Toggles Record Mode On/Off

F3 Displays the search/replace dialog, or searches if the dialog is already open.

Ctrl-Alt-Right Starts playing from the current item.

Ctrl-Alt-Space Stops Playing

Ctrl+F5 Plays entire hierarchy from the current item. (Note: if focus is inside the browser, IE will intercept as "Refresh").

F6 Single steps (plays next single item in script.)

F8 Shows/Hides Script Tree

F9 Shows/Hides Summary Tab View

F12 Shows/Hides both Script and Summary Views together (gives browser full window space)

Ctrl+Enter Replays the item current item in the script

Ctrl+Shift+Enter Replays the current step in the script

Ctrl+Shift+Left Rewinds the play marker to the previous step.

Ctrl+Alt+Up Moves the play marker to the previous item in script.

Ctrl+Alt+Down Moves the play marker to the previous item in script.

Ctrl+L Displays the lines Server Log File related to the most recent browsing activity.

Ctrl+K Clears all responses from the Script.

Ctrl+J Attempts to find and edit the source code file for the current page and/or frame that has focus in the browser.

Ctrl+Shift+J Attempts to find and edit the source code file for the current page and/or frame that has focus in the browser and also adds the URL for the frame to your script as a Monitored request.

Ctrl+Shift+M Adds URLs for all frames in the current browser as Monitored requests.

Ctrl+D Toggles DOM View On/Off for the active window.

Ctrl+Page Up While in DOM View changes to previous frame in frame list

Ctrl+Page Down While in DOM View changes to next frame in frame list

Ctrl+Alt Changes Record Mode temporarily to Navigation Mode while held down

Ctrl+Alt+N Toggles record mode between Navigation and Request mode

Ctrl+Shift+D Opens the documentation editor for the item currently selected in the Script Tree.

 
發佈了34 篇原創文章 · 獲贊 0 · 訪問量 9萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章