QTP是自動化測試的工具,可以使用編寫腳本或錄制的方式進行測試自動化:
下面是對Windows自帶計算器的測試
首先寫入腳本,使用VBScript打開計算器
Dim oShell
Set oShell=CreateObject("WSCript.shell")
oShell.Run "calc",1
Wait 2
然后錄制
將自動產生腳本,然后在Edit后加入檢查點,測試1+1=2(Insert->CheckPoint->Text Area CheckPoint)
界面如下:
設置要檢查的值為2.
最后的腳本為
Dim oShell Set oShell=CreateObject("WSCript.shell") oShell.Run "calc",1 Wait 2 Window("計算器").WinButton("1").Click Window("計算器").WinButton("+").Click Window("計算器").WinButton("1").Click Window("計算器").WinButton("=").Click Window("計算器").WinEdit("Edit").Check CheckPoint("Edit_2") Window("計算器").Close
運行后,會自動產生一個報告:(為了測試錯誤的信息,本人在檢測點附近設置了值為3.)