QTP測試Windows計算器


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.)

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM