1.WinRunner如何把Real類型轉化為指數表示方法
答:指數類型轉化為real類型,可以通過下邊的代碼
clearcase/" target="_blank" >cccccc>var = 5.3569E+10; pause(var); #顯示 53569000000 |
Real類型轉化為指數表示方式
var = sprintf("%e",53568544768); pause(var); #displays 5.356854e+010 |
2.什么是同步點,怎樣用它?他和Wait有什么不同?
答: 從功能上他們都可以實現腳本和被測試程序同步的問題,不過同步點有window/object,bitmap方式,她等待的是某個等待的對象窗體,bitmap的出現,一定程度她也可以作為驗證點wait這點上無法實現相同的效果。有的腳本中即使你加入wait,但是你無法知道下邊的對象窗體圖片是否就是成需要運行的正確出現的
3.tl_step和tl_step_once的區別
答:tl_step和tl_step_once都是把運行狀態信息放到運行結果中去,區別在如果連接TD,TL_STEP把每步狀態信息都插入到測試結果中去,tl_step_once如果連接td,只是插入一次運行步驟的名字
代碼例子:
--------------------------------------------------------------------------------
for (i=1;i<4;i++){
tl_step("Step", PASS, "reporting step, #" &i);
tl_step_once("Step Once", PASS, "reporting step once, #" &i);
}
--------------------------------------------------------------------------------
WR中的報告:
Step: Step, Status: PASS, Description: reporting step, #1
Step: Step Once, Status: PASS, Description: reporting step once, #1
Step: Step, Status: PASS, Description: reporting step, #2
Step: Step Once, Status: PASS, Description: reporting step once, #2
Step: Step, Status: PASS, Description: reporting step, #3
Step: Step Once, Status: PASS, Description: reporting step once, #3
TD中的報告:
Step: Step, Status: PASS, Description: reporting step, #1
Step: Step Once, Status: PASS, Description: reporting step once, #1
Step: Step, Status: PASS, Description: reporting step, #2
Step: Step, Status: PASS, Description: reporting step, #3
4.WinRunner和TD集成后腳本運行很慢是什么原因呢?
答:安裝TD和WinRunner服務器上需要獨占100GByte,TD需要10OGHZ時鐘速度16GB RAM的處理平臺
5.WR是否支持vs.net
根據Mercury的介紹,他們的對.Net的支持轉移到QuickTest Pro上了,如果你需要自動化測試.Net程序(不是web的),建議用
QuickTestPro。也就是說wr不支持vs.net開發的程序 6.我對比兩個文件file1.txt和file2.txt,文本內容如下
file1.txt 內容如下:
10523 8315 6804 8387 3643 4550 3457 3649
7.如何在winRunner中用Windows的API函數
在使用該API函數前需要先加載該函數然后聲明API函數,代碼如下
load_dll("user32.dll"); extern int PostMessageA(in long, in long, in long, in long); win_get_info("{class:window, MSW_class:AfxMDIFrame42, label:\"!WinRunner.*\"}", "handle", hWnd); PostMessageA(hWnd, 16, 0, 0); |
請在嘗試以上代碼的時候,保存腳本,呵呵!
8.怎樣處理跟蹤鍵盤操作?
答:下邊的代碼希望對你有幫助
function GetKeyStatus(in vKey){ auto pid, thread_id, win_desc, hWnd, KeyState, win_log_name, win_full_desc, focused_obj_desc; win_desc = "{active:1}"; if (win_exists(win_desc)==0) { win_get_desc(win_desc, "", "", "", win_full_desc); GUI_map_get_logical_name( win_full_desc, "", win_log_name, "bla"); win_get_info(win_desc, "handle", hWnd); pid = GetWindowThreadProcessId(hWnd, NULL); thread_id=GetCurrentThreadId(); AttachThreadInput(pid,thread_id,TRUE); KeyState=GetKeyState (vKey); AttachThreadInput(pid,thread_id,FALSE); if (KeyState < 0) return(0); # Key is pressed else return (1); # Key is not pressed } else return (-1); # No active window found, so cannot determine key state } |
9.WinRunner如何處理excel?
答:其實解決方法有很多,這里列舉兩種。
一.利用其他語言特性開發出dll提供給winrunner使用(vb,vc,delphi等)
二.在其他環境中實現,用winrunner調用
第一種我在這里不舉例子了,第二種我利用vbs往excel中賦值給大家提供一種思路,代碼如下:
'vbs中的代碼 ExcelApp.ActiveWorkbook.Save() end if winrunner中的調用代碼: |
10.在WinRunner中如何實現得到transaction時間?
答:一般情況下transaction的時間只能在最后結果中得到,如何在腳本得到這個時間呢,下邊的代碼可以
幫助你:
public transactions[]; transactions[transaction_name]); never started."); & (rc = end_time - transactions[transaction_name])); start_my_transaction("my_transaction"); |
原文轉自:http://www.anti-gravitydesign.com