01_Login
'判断并结束flight4a.exe进程
Set objWMIService = GetObject("winmgmts:\\.\root\cimv2")' 建立任务管理对象,遍历进程
Set colProcessList=objWMIService.ExecQuery ("select * from Win32_Process where Name='flight4a.exe' ")' 查找filght4a.exe进程
For Each objProcess in colProcessList ' 循环
objProcess.Terminate() ' 结束进程
Next
Systemutil.Run "C:\Program Files (x86)\HP\Unified Functional Testing\samples\flight\app\flight4a.exe"' 运行flight4a.exe
' 从外部导入表
Dim rownum
rownum=DataTable.GetSheet("Global").GetRowCount
If rownum=0 Then
DataTable.Import "..\table.xls"
End If
' 登陆系统(使用环境变量登陆)
Dialog("Login").Activate
Dialog("Login").WinEdit("Agent Name:").Set Environment("AgentName")' 将AgentName定义成环境变量,从xml表中读值
Dialog("Login").WinEdit("Password:").SetSecure Environment("Password")' 将Password定义为环境变量,从xml表中读值
Dialog("Login").WinButton("OK").Click
02_New_Order
' 新建订单
Window("Flight Reservation").Activate
Window("Flight Reservation").WinButton("New").Click
Window("Flight Reservation").ActiveX("MaskEdBox").Type DataTable("p_KeyboardInput", dtLocalSheet)' 从本地表读入日期数据
Window("Flight Reservation").WinComboBox("Fly From:").Select DataTable("p_FlyFrom", dtLocalSheet)' 从本地表读入出发地
Window("Flight Reservation").WinComboBox("Fly To:").Select DataTable("p_FlyTo", dtLocalSheet)' 从本地表读入到达地
Window("Flight Reservation").WinButton("FLIGHT").Click
' 选择订票
Window("Flight Reservation").Dialog("Flights Table").WinButton("OK").Click
' 输入订票人信息及票数
Window("Flight Reservation").WinEdit("Name:").Set DataTable("p_Name", dtLocalSheet)' 从本地表读入订票人
Window("Flight Reservation").WinRadioButton("Business").Set
Window("Flight Reservation").WinEdit("Tickets:").SetSelection 0,1
Window("Flight Reservation").WinEdit("Tickets:").Set DataTable("p_Tickets", dtLocalSheet)' 从本地读入订票数
Window("Flight Reservation").WinButton("Insert Order").Click
Window("Flight Reservation").ActiveX("Threed Panel Control").WaitProperty "text", "Insert Done...", 10000' 同步点
Window("Flight Reservation").WinEdit("Order No:").Output CheckPoint("Order No:")' 标准输出
03_Open_Order
' 设置循环次数
row=DataTable.GetSheet("02_New Order").GetCurrentRow' 读取2表当前指向的数字
For Iterator = 1 To row ' 设置循环
DataTable.GetSheet("02_New Order"). SetCurrentRow(Iterator)' 循环指向从1依次到row
' 打开订单
Window("Flight Reservation").Activate
Window("Flight Reservation").WinButton("open").Click
Window("Flight Reservation").Dialog("Open Order").WinCheckBox("Order No.").Set "ON"
Window("Flight Reservation").Dialog("Open Order").WinEdit("Edit").Set DataTable("Order_No_text_out", "02_New Order")
Window("Flight Reservation").Dialog("Open Order").WinButton("OK").Click
wait(1) ' 等待1秒读值
date1=DataTable("p_KeyboardInput", "02_New Order")
date2=Window("Flight Reservation").ActiveX("MaskEdBox").GetROProperty("text")
date2=left(date2,2)&mid(date2,4,2)&right(date2,2) ' 将日期中的"/"去掉
'另一种方法:date2=replace(date2,"/","")
' 判断日期是否符合
If date1=date2 Then
Reporter.ReportEvent micPass,"日期匹配","日期正确,两者匹配"
else
Reporter.ReportEvent micFail,"日期不匹配","日期不正确,两者不匹配"
End If
from1=Window("Flight Reservation").WinComboBox("Fly From:").GetROProperty("text")
from2=DataTable("p_FlyFrom", "02_New Order") ' 从2表获取出发地点
' 判断出发地点是否符合
If from1=from2 Then
Reporter.ReportEvent micPass,"出发地点匹配","出发地点与选定地点匹配"
else
Reporter.ReportEvent micFail,"出发地点不匹配","出发地点与选定地点匹配"
End If
to1=Window("Flight Reservation").WinComboBox("Fly To:").GetROProperty("text")
to2=DataTable("p_FlyTo", "02_New Order") ' 从2表获取到达地点
' 判断到达地点是否符合
If to1=to2 Then
Reporter.ReportEvent micPass,"到达地点匹配","到达地点与选定地点匹配"
else
Reporter.ReportEvent micFail,"到达地点不匹配","到达地点与选定地点不匹配"
End If
num1=Window("Flight Reservation").WinEdit("Tickets:").GetROProperty("text")
num2=DataTable("p_Tickets", "02_New Order") ' 从2表获取订票数
' 判断订票数是否符合
If num1=num2 Then
Reporter.ReportEvent micPass,"订票数匹配","订票数与选定票数匹配"
else
Reporter.ReportEvent micFail,"订票数不匹配","订票数与选定票数匹配"
End If
name1=Window("Flight Reservation").WinEdit("Name:").GetROProperty("text")
name2=DataTable("p_Name", "02_New Order") ' 从2表获取订票人
' 判断订票人是否符合
If name1=name2 Then
Reporter.ReportEvent micPass,"姓名匹配","姓名与输入姓名匹配"
else
Reporter.ReportEvent micFail,"姓名不匹配","姓名与输入姓名不匹配"
End If
' 发传真
Window("Flight Reservation").WinMenu("Menu").Select "File;Fax Order..."
Window("Flight Reservation").Dialog("Fax Order No.").Activate' 设置正则表达式,以确保每次发送均可找到该窗口
Window("Flight Reservation").Dialog("Fax Order No.").ActiveX("MaskEdBox").Type "1112223333"
Window("Flight Reservation").Dialog("Fax Order No.").WinButton("Send").Click
Window("Flight Reservation").Activate
Window("Flight Reservation").ActiveX("Threed Panel Control").WaitProperty "text", "Fax Sent Successfully...", 10000' 同步点
Next
04_Logout
' 退出系统
Window("Flight Reservation").WinMenu("Menu").Select "File;Exit"' 关闭系统
文章转载自http://blog.csdn.net/liyang19931127/article/details/49405613