QTP的飛機登錄描述性編程
在QTP中,要先去錄制用戶名和密碼,錯誤的一次和正確的一次,對于錯誤所彈出的對話框要進行建立文本的檢查點,以便datatable的用例進行比對。用戶名和密碼要進行參數(shù)化,在進行判斷。
Dim url url="C:\Program Files\Mercury Interactive\QuickTest Professional\samples\flight\app\flight4a.exe" if Dialog("text:=Login").Exist(1) then OptionalStep.Dialog("text:=Login").WinEdit("attached text:=Agent Name:").Set DataTable("p_Text", dtGlobalSheet) OptionalStep.Dialog("text:=Login").WinEdit("attached text:=Password:").Set DataTable("p_Text1", dtGlobalSheet) OptionalStep.Dialog("text:=Login").WinButton("text:=OK").Click wait(1) else |
如果QTP不能自己打開被測試程序就使用該功能打開
systemUtil.Run url OptionalStep.Dialog("text:=Login").WinEdit("attached text:=Agent Name:").Set DataTable("p_Text", dtGlobalSheet) OptionalStep.Dialog("text:=Login").WinEdit("attached text:=Password:").Set DataTable("p_Text1", dtGlobalSheet) OptionalStep.Dialog("text:=Login").WinButton("text:=OK").Click wait(1) end if |
檢查點
if Dialog("text:=Login").Dialog("text:=Flight Reservations").Exist(2) then dim errorinfor,odesc set desc=description.Create odesc("text").value=DataTable("error",dtGlobalSheet) errorinfor=Dialog("text:=Login").Dialog("text:=Flight Reservations").Static(odesc).GetROProperty("text") Dialog("text:=Login").Dialog("text:=Flight Reservations").WinButton("text:=確定").Click |
學習一下Reporter方法的用法
Reporter.ReportEvent micDone,"登陸驗證失敗,提示信息如下",errorinfor OptionalStep.Dialog("text:=Login").close wait(1) else |
如果用戶名和密碼正確就進入訂票頁面
If Window("text:=Flight Reservation").Exist(10) then Reporter.ReportEvent micPass,"登陸驗證通過","用戶名密碼正確" Window("text:=Flight Reservation").close wait(1) Set desc=Nothing end if end if |
飛機登錄描述性編程圖片
測試結(jié)果
版權(quán)聲明:本文出自 shujin6040 的51Testing軟件測試博客:http://www.51testing.com/?597535
原創(chuàng)作品,轉(zhuǎn)載時請務(wù)必以超鏈接形式標明本文原始出處、作者信息和本聲明,否則將追究法律責任。
posted on 2013-11-08 14:13 順其自然EVO 閱讀(297) 評論(0) 編輯 收藏 所屬分類: qtp