功能测试
目的:练习描述性编程的直接描述方法、Description对象、ChildObject方法,并思考用描述性编程来解决实际问题。
题目:飞机订票系统业务流程为登陆Flight->创建订单->打开订单,验证飞机订票系统能使用客户名称和日期搜索成功打开刚创建的订单。
要求 :
1. 所有代码均使用描述性编程手动编写完成,不使用任何对象库。
2. 在打开订单时,在通过客户名称和日期的搜索结果里面选择最新创建的订单打开。
3. 验证被打开的订单的订单号与创建订单时生成的订单号一致。(使用自定义检查点)
4. 该脚本创建订单时需使用下列两组数据:
Date |
FlyFrom |
FlyTo |
Name |
Class(航班种类) |
121315 |
Denver |
London |
zhangsan |
经济舱(Economy) |
121415 |
London |
Paris |
lisi |
商务舱(Business) |
交付物:提交UFT测试脚本和测试报告PDF。
============================================================================
'姓名:x先生
'邮箱:[email protected]
'更新日期:xxx年x月x日
'描述:飞机订票系统的登录
============================================================================
'启动被测应用程序
SystemUtil.Run "D:\HP\samples\flight\app\flight4a.exe"
'登录脚本 - 直接描述性编程
With Dialog("text:=login")
.WinEdit("Window id:=3001").Set "name01"
.WinEdit("Window id:=2000").Set "mercury"
.WinButton("Window id:=1").Click
End With
'登录脚本 - Description
'Set objLoginDes = Description.Create()
'objLoginDes("text").Value="Login"
'Set objAgentDes = Description.Create()
'objAgentDes("Window id").Value="3001"
'Set objPwdDes = description.Create()
'objPwdDes("Window id").Value="2000"
'Set objOkDes = description.Create()
'objOkDes("Window id").Value=1
============================================================================
'姓名:x先生
'邮箱:[email protected]
'更新日期:xxx年x月x日
'描述:飞机订票系统的创建新订单
============================================================================
'创建新订单
With Window("text:=Flight ReserVation")
.WinButton("Window id:=6").Click
'输入时间
.ActiveX("acx_name:=MaskEdBox").Type DataTable("Date",dtGlobalSheet)
'输入出发地
.WinComboBox("attached text:=Fly From:").Select DataTable("FlyFrom", dtGlobalSheet)
'输入目的地
.WinComboBox("attached text:=Fly To:").Select DataTable("FlyTo", dtGlobalSheet)
'点击Flights 按钮
.WinButton("window id:=2025").Click
'确定订单
.Dialog("text:=Flights Table").WinButton("window id:=1").Click
'输入名字
.WinEdit("window id:=1014").Set DataTable("Name",dtGlobalSheet)
.WinRadioButton("text:="&DataTable("Class", dtGlobalSheet)).Click
.WinButton("window id:=1008").Click
'设置同步点
.ActiveX("progid:=Threed.SSPanel").WaitProperty "text", "Insert Done...", 10000
.WinButton("window id:=6").Click
End With
============================================================================
'姓名:x先生
'邮箱:[email protected]
'更新日期:xxx年x月x日
'描述:通过姓名和订票日期来搜索订单,以及判断单号是否一致
============================================================================
With Window("text:=Flight Reservation")
'打开订单
.WinMenu("menuobjtype:=2","Class Name:=WinMenu").Select "File;Open Order..."
'定义一个变量
Dim Orderr
'获取值
Orderr = .WinEdit("window id:=1016").GetROProperty("text")
'选择姓名搜索
.Dialog("text:=Open Order").WinCheckBox("text:=Customer &Name","Class Name:=WinCheckBox").Set "ON"
'从Global 表中获取姓名(参数化姓名)
.Dialog("text:=Open Order").WinEdit("window id:=1014").Set DataTable("Name",dtGlobalSheet)
.Dialog("text:=Open Order").WinCheckBox("text:=&Flight Date","Class Name:=WinCheckBox").Set "ON"
'从Global 表中获取时间(参数化获取的时间)
.Dialog("text:=Open Order").ActiveX("NativeClass:=MSMaskWndClass").Type DataTable("Date",dtGlobalSheet)
'点击OK 按钮
.Dialog("text:=Open Order").WinButton("window id:=1").Click
'定义一个变量
Dim Order
Order = .WinEdit("window id:=1016").GetROProperty("text")
Dim Sum
'获取搜索页中的订单
Sum = .Dialog("text:=Open Order").Dialog("text:=Search Results").WinList("attached text:=Flight No.").GetItemsCount
.Dialog("text:=Open Order").Dialog("text:=Search Results").WinList("attached text:=Flight No.").Select(sum-1)
.Dialog("text:=Open Order").Dialog("text:=Search Results").WinButton("window id:=1").Click
End With
'判断Order=Orderr是否一致,一致则通过,不一致则失败
If Order=Orderr Then
Reporter.ReportEvent micPass, "success", "Pass"
Else
Reporter.ReportEvent micFail, "disuccess", "Fail"
End If
============================================================================
'姓名:x先生
'邮箱:[email protected]
'更新日期:xxx年x月x日
'描述:关闭并退出系统
============================================================================
'关闭并退出系统
Window("text:=Flight Reservation").Close