qileilove

blog已经转移至github,大家请访问 http://qaseven.github.io/

QTP的飞机登录描述性编程

QTP中,要先去录制用户名和密码,错误的一次和正确的一次,对于错误所弹出的对话框要进行建立文本的检查点,以便datatable的用例进行比对。用户名和密码要进行参数化,在进行判断。
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

飞机登录描述性编程图片
  测试结果
版权声明:本文出自 shujin6040 的51Testing软件测试博客:http://www.51testing.com/?597535
原创作品,转载时请务必以超链接形式标明本文原始出处、作者信息和本声明,否则将追究法律责任。

posted on 2013-11-08 14:13 顺其自然EVO 阅读(285) 评论(0)  编辑  收藏 所属分类: qtp


只有注册用户登录后才能发表评论。


网站导航:
 
<2013年11月>
272829303112
3456789
10111213141516
17181920212223
24252627282930
1234567

导航

统计

常用链接

留言簿(55)

随笔分类

随笔档案

文章分类

文章档案

搜索

最新评论

阅读排行榜

评论排行榜