(1)公用函数封装。 在本实例中需要封装的函数主要包括:读取测试用例、输入每个测试用例的测试结果。 通过获取单元格中数据的行数,可以确定测试用例文档中有多少条测试用例,代码如下:
'*************************************************************' '函数/过程名称:GetExcelSheetRowsCount '函数/过程的目的:获取 Sheet 表中记录行数 '假设:无 '影响:无 '输入:无 '返回值:记录行数 '创建者:黄文高 '创建时间:2010/08/11 '修改者: '修改原因: '修改时间: '*************************************************************' Function GetExcleSheetRowsCount(ExcelPath,SheetName) Set ExcelBook = CreateObject("Excel.Application") Set ExcelSheet = CreateObject("Excel.Sheet")Set myExcelBook = ExcelBook.WorkBooks.Open(ExcelPath) Set myExcelSheet = myExcelBook.WorkSheets(SheetName) GetExcleSheetRowsCount = myExcelSheet.UsedRange.Rows.Count ExcelBook.Quit Set ExcelSheet = Nothing Set ExcelBook = Nothing End Function
读取单元格中的数据,即获得测试用例值,代码如下:'*************************************************************' '函数/过程名称:GetExcelCells '函数/过程的目的:读取 Excel 表中单元格的值 '假设:无 '影响:无 '输入:无 '返回值:Excel 表中单元格的值 '创建者:黄文高 '创建时间:2010/08/11 '修改者: '修改原因: '修改时间: '*************************************************************' Function GetExcelCells(ExcelPath,SheetName,SheetColumn,SheetRow) Set ExcelBook = CreateObject("Excel.Application") Set ExcelSheet = CreateObject("Excel.Sheet") Set myExcelBook = ExcelBook.WorkBooks.Open(ExcelPath) Set myExcelSheet = myExcelBook.WorkSheets(SheetName) SheetValue = myExcelSheet.cells(SheetColumn,SheetRow).Value GetExcelCells = SheetValue ExcelBook.Quit Set ExcelSheet = Nothing Set ExcelBook = Nothing End Function 在该实例中还需要记录每个测试用例执行的结果,封装的代码如下: '*************************************************************' '函数/过程名称:CreateHtmlLog '函数/过程的目的:创建 HTML 格式的日志文件,并写 Header '假设:无 '影响:无 '输入:无 '返回值:无 '创建者:黄文高
'创建时间:2010/08/09 '修改者: '修改原因: '修改时间: '*************************************************************' Public Sub CreateHtmlLog() Const ForReading = 1, ForWriting = 2, ForAppending = 8 Dim fileSystemObj, fileSpec Dim currentTime currentDate = Date currentTime = Time testName = environment.Value("TestName") Set fileSystemObj = CreateObject("Scripting.FileSystemObject") fileSpec =TestPath&"测试记录\"&testName& ".html" Set logFile = fileSystemObj.OpenTextFile(fileSpec, ForAppending, False, True) logfile.writeline("<html>") logfile.writeline("<title>Test LogFile</title>") logfile.writeline("<head></head>") logfile.writeline("<body>") logfile.writeline("<font face='Tahoma'size='2'>") logfile.writeline("<h1>Test LogFile</h1>") logfile.writeline("<table border='0' width='100%' height='47'>") logfile.writeline("<tr>") logfile.writeline("<td width='20%' bgcolor='#CCCCFF'><b><font color='#000000' face='Tahoma' size='2'>TestCaseName</font></b></td>") logfile.writeline("<td width='20%' bgcolor='#CCCCFF'><b><font color='#000000' face='Tahoma' size='2'>TestCaseID</font></b></td>") logfile.writeline("<td width='10%' bgcolor='#CCCCFF'><b><font color='#000000' face='Tahoma' size='2'>TestResult</font></b></td>") logfile.writeline("<td width='10%' bgcolor='#CCCCFF'><b><font color='#000000' face='Tahoma' size='2'>TestTime</font></b></td>") logfile.writeline("<td width='20%' bgcolor='#CCCCFF'><b><font color='#000000' face='Tahoma' size='2'>ActualValue</font></b></td>") logfile.writeline("<td width='20%' bgcolor='#CCCCFF'><b><font color='#000000' face='Tahoma' size='2'>ExpectValue</font></b></td>") logfile.writeline("</tr>") logFile.Close Set logFile = Nothing End Sub '*************************************************************' '函数/过程名称:WriteHtml '函数/过程的目的:写 HTML 日志文件'假设:无 '影响:无 '输入:无 '返回值:无 '创建者:黄文高 '创建时间:2010/08/09 '修改者: '修改原因: '修改时间: '*************************************************************' Function WriteHtml(BusinessName,TestCaseID,TestResult,TestTime,ActualValue,ExpectValue) Const ForReading = 1, ForWriting = 2, ForAppending = 8 Dim fileSystemObj, fileSpec Dim currentTime currentDate = Date currentTime = Time testName = environment.Value("TestName") Set fileSystemObj = CreateObject("Scripting.FileSystemObject") fileSpec =TestPath&"测试记录\"&testName& ".html" Set logFile = fileSystemObj.OpenTextFile(fileSpec, ForAppending, False, True) logfile.writeline("<table border='0' width='100%' height='47'>") logfile.writeline("<tr>") logfile.writeline("<td width='20%' bgcolor='#CCCCFF'><b><font color='#000000' face='Tahoma' size='2'>"& BusinessName &"</font></b></td>") logfile.writeline("<td width='20%' bgcolor='#CCCCFF'><b><font color='#000000' face='Tahoma' size='2'>"& TestCaseID &"</font></b></td>") if ucase(TestResult) = "Pass" then logfile.writeline("<td width='10%' bgcolor='#CCCCFF'><b><font color= '#006000' face='Tahoma' size='2'>"& ucase(TestResult) &"</font></b></td>") else logfile.writeline("<td width='10%' bgcolor='#CCCCFF'><b><font color= '#CE0000' face='Tahoma' size='2'>"& ucase(TestResult) &"</font></b></td>") end if logfile.writeline("<td width='10%' bgcolor='#CCCCFF'><b><font color='#000000' face='Tahoma' size='2'>"& TestTime &"</font></b></td>") logfile.writeline("<td width='20%' bgcolor='#CCCCFF'><b><font color='#000000' face='Tahoma' size='2'>"& ActualValue &"</font></b></td>") logfile.writeline("<td width='20%' bgcolor='#CCCCFF'><b><font color='#000000' face='Tahoma' size='2'>"& ExpectValue &"</font></b></td>") logfile.writeline("</tr>")logfile.writeline("</boby>") logfile.writeline("</html>") logFile.Close Set logFile = Nothing end function 由于在本实例中需要连接数据库,检查数据库中的数据是否正确,所以将连接数据库的代码进 行封装,代码如下: '*************************************************************' '函数/过程名称:ConnectDatabase '函数/过程的目的:连接数据库 '假设:无 '影响:无 '输入:无 '返回值:无 '创建者:黄文高 '创建时间:2010/09/09 '修改者: '修改原因: '修改时间: '*************************************************************' Sub ConnectDatabase() StrConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source= C:\Program Files\HP\QuickTest Professional\samples\flight\app\flight32.mdb;Persist Security Info=False" Set Conn = CreateObject("Adodb.Connection") Set Rst = CreateObject("Adodb.RecordSet") Conn.Open StrConn End Sub (2)单一模式脚本开发。 自动化测试脚本开发完成后,开始录制脚本,这个阶段主要是将自动化测试的需求转换为一个 简单的脚本。 1)录制登录过程的脚本如下: Dialog("Login").WinEdit("Agent Name:").Set "test" Dialog("Login").WinEdit("Password:").SetSecure "4f746e8c4a42371e29270aa8077835adfd4e3e6f" Dialog("Login").WinButton("OK").Click wait(5) Window("Flight Reservation").Close 2)录制订票流程的脚本如下: Dialog("Login").WinEdit("Agent Name:").Set "test" Dialog("Login").WinEdit("Password:").SetSecure "4f7470899cb23413741ea878e508c7c39c26d007" Dialog("Login").WinButton("OK").Click wait(5)Window("Flight Reservation").ActiveX("MaskEdBox").Type "040412" Window("Flight Reservation").WinComboBox("Fly From:").Select "Frankfurt" Window("Flight Reservation").WinComboBox("Fly To:").Select "Los Angeles" Window("Flight Reservation").WinButton("FLIGHT").Click Window("Flight Reservation").Dialog("Flights Table").WinList("From").Select "20332 FRA 10:12 AM LAX 05:23 PM AA $112.20" Window("Flight Reservation").Dialog("Flights Table").WinButton("OK").Click Window("Flight Reservation").WinEdit("Name:").Set "arivn" Window("Flight Reservation").WinButton("Insert Order").Click Window("Flight Reservation").Close 3)录制航班信息的脚本如下: Dialog("Login").WinEdit("Agent Name:").Set "test" Dialog("Login").WinEdit("Password:").SetSecure "4f7470899cb23413741ea878e508c7c39c26d007" Dialog("Login").WinButton("OK").Click wait(5) Window("Flight Reservation").ActiveX("MaskEdBox").Type "040412" Window("Flight Reservation").WinComboBox("Fly From:").Select "Frankfurt" Window("Flight Reservation").WinComboBox("Fly To:").Select "Los Angeles" Window("Flight Reservation").WinButton("FLIGHT").Click Window("Flight Reservation").Dialog("Flights Table").WinList("From").Select "20332 FRA 10:12 AM LAX 05:23 PM AA $112.20" Window("Flight Reservation").Close 4)录制查询订票信息的脚本如下: Dialog("Login").WinEdit("Agent Name:").Set "test" Dialog("Login").WinEdit("Password:").SetSecure "4f7474b213b5bb9f7e950286e72b5f0d7487449b" Dialog("Login").WinButton("OK").Click wait(5) Window("Flight Reservation").WinMenu("Menu").Select "File;Open Order..." Window("Flight Reservation").Dialog("Open Order").WinCheckBox("Order No.").Set "ON" Window("Flight Reservation").Dialog("Open Order").WinEdit("Edit").Set "42" Window("Flight Reservation").Dialog("Open Order").WinButton("OK").Click Window("Flight Reservation").Close (3)脚本增强。 录制好的单一模式脚本的功能很弱,只完成了一个简单的功能,不具备可扩展性,无法兼容不 同的测试数据,所以需要对上面的脚本进行增强。在录制单一模式的脚本时,其实有一个功能是通 用的,就是登录功能,每个操作的功能都需要先登录系统,所以可将一个正确登录的脚本封装成一 个过程,这样可以节约脚本量,也便于维护脚本。在封装登录过程时,需要使用到描述性编程,封 装的代码如下: Sub Login() Dialog("text:=Login").WinEdit("attached text:=Agent Name:").Set "test"Dialog("text:=Login").WinEdit("attached text:=Password:").SetSecure "4f746e8c4a42371e29270aa8077835adfd4e3e6f" Dialog("text:=Login").WinButton("text:=OK").Click wait(5) End Sub 接着对登录的脚本进行增强操作,增强的原因是脚本需要能正确处理当输入用户名或密码出错 的情况。主要需要处理的情况有:输入的用户名为空、输入的用户名少于 4 个字符、输入的密码为 空、输入的密码少于 4 个字符。登录功能增强后的脚本如下: Dim errInfo '返回提示的错误信息 Dialog("Login").WinEdit("Agent Name:").Set "test" Dialog("Login").WinEdit("Password:").SetSecure "4f772505bb7ff00c6ec281f9808222c2e89cf0ec" Dialog("Login").WinButton("OK").Click If Dialog("Login").Dialog("Flight Reservations").Exist Then errInfo = Dialog("text:=Login").Dialog("text:=Flight Reservations").Static("window id:=65535"). GetROProperty("text") Dialog("Login").Dialog("Flight Reservations").WinButton("确定").Click Dialog("Login").Close else wait(5) Window("Flight Reservation").Close End If 订票流程脚本的增强主要需要处理订票日期未输入和输入错误的情况,订票流程功能增强后的 脚本如下: Dim errinfo '返回提示的错误信息 Dialog("Login").WinEdit("Agent Name:").Set "test" Dialog("Login").WinEdit("Password:").SetSecure "4f7729c18243dcb0a80aed533ae02ea81b074338" Dialog("Login").WinButton("OK").Click wait(5) Window("Flight Reservation").ActiveX("MaskEdBox").Type "121212" Window("Flight Reservation").WinComboBox("Fly From:").Select "San Francisco" If Window("Flight Reservation").Dialog("Flight Reservations").Exist Then errinfo = Window("regexpwndtitle:=Flight Reservation").Dialog("text:=Flight Reservations"). Static("window id:=65535").GetROProperty("text") Window("Flight Reservation").Dialog("Flight Reservations").WinButton("确定").Click else Window("Flight Reservation").WinComboBox("Fly To:").Select "London" Window("Flight Reservation").WinButton("Flight").Click Window("Flight Reservation").Dialog("Flights Table").WinList("From").Select "13800 SFO 10:24 AM LON 12:54 PM AF $127.47" Window("Flight Reservation").Dialog("Flights Table").WinButton("OK").Click Window("Flight Reservation").WinEdit("Name:").Set "arivn" Window("Flight Reservation").WinButton("Insert Order").Click End If Window("Flight Reservation").Close 航班信息查询脚本的增强主要是需要检查当选择出发城市和到达城市后,显示出来的航班信息 是否正确,脚本增强时需要获取所有航班信息。增强后的脚本如下: Dim flightinfo '显示所有航班信息 Dialog("Login").WinEdit("Agent Name:").Set "test" Dialog("Login").WinEdit("Password:").SetSecure "4f7862cc49d3bfca65cfd26a9797bdbfab09733a" Dialog("Login").WinButton("OK").Click wait(5) Window("Flight Reservation").ActiveX("MaskEdBox").Type "121212" Window("Flight Reservation").WinComboBox("Fly From:").Select "Frankfurt" Window("Flight Reservation").WinComboBox("Fly To:").Select "London" Window("Flight Reservation").WinButton("Flight").Click flightInfo = Window("Flight Reservation").Dialog("Flights Table").WinList("From").GetROProperty("all items") Window("Flight Reservation").Dialog("Flights Table").WinButton("OK").Click Window("Flight Reservation").Close 查询订票信息脚本增强主要是需要检查该航班号是否存在,如果航班号不存在,会弹出相应的 对应信息;如果查询的订单号存在,就会显示出该订单的相关信息。增强后的脚本如下: Dialog("Login").WinEdit("Agent Name:").Set "test" Dialog("Login").WinEdit("Password:").SetSecure "4f78720180a456bfe5666600e64d62d0553bc374" Dialog("Login").WinButton("OK").Click wait(5) Window("Flight Reservation").WinMenu("Menu").Select "File;Open Order..." Window("Flight Reservation").Dialog("Open Order").WinCheckBox("Order No.").Set "ON" Window("Flight Reservation").Dialog("Open Order").WinEdit("Edit").Set "55555" Window("Flight Reservation").Dialog("Open Order").WinButton("OK").Click If Window("Flight Reservation").Dialog("Open Order").Dialog("Flight Reservations").Exist Then errInfo = Window("regexpwndtitle:=Flight Reservation").Dialog("text:=Open Order").Dialog ("regexpwndtitle:=Flight Reservations").Static("window id:=65535").GetROProperty("text") Window("Flight Reservation").Dialog("Open Order").Dialog("Flight Reservations").WinButton("确定").Click Window("Flight Reservation").Dialog("Open Order").Dialog("Flight Reservations").Close End If Window("Flight Reservation").Close (4)调用测试用例,判断测试结果。 仅仅通过上面对脚本增强还不够,不能做到真正的自动化测试,还必须让脚本正确地执行所有 用例,并且同时判断每个测试用例执行的结果。 对于登录功能调用测试用例后的脚本如下: Dim errInfo '返回提示的错误信息 For i=3 to GetExcleSheetRowsCount("C:\testcase","Login") BusinessName = GetExcelCells(ReadExcelPath,"Login",i,3) TestCaseID = GetExcelCells(ReadExcelPath,"Login",i,2) ReadString = GetExcelCells("C:\testcase","Login",i,6) arrExcelLines = split(ReadString,",") systemutil.Run "C:\Program Files\HP\QuickTest Professional\samples\flight\app\flight4a.exe","","","" Dialog("Login").WinEdit("Agent Name:").Set arrExcelLines(0) Dialog("Login").WinEdit("Password:").SetSecure arrExcelLines(1) Dialog("Login").WinButton("OK").Click If Dialog("Login").Dialog("Flight Reservations").Exist Then errInfo = Dialog("text:=Login").Dialog("text:=Flight Reservations").Static("window id:=65535").GetROProperty("text") If errInfo = GetExcelCells("C:\testcase","Login",i,7) Then WriteHtml BusinessName,TestCaseID,"PASS",date,errInfo,GetExcelCells("C:\testcase", "Login",i,7) else WriteHtml BusinessName,TestCaseID,"FAIL",date,errInfo,GetExcelCells("C:\testcase", "Login",i,7) End If Dialog("Login").Dialog("Flight Reservations").WinButton("确定").Click Dialog("Login").Close else wait(5) WriteHtml BusinessName,TestCaseID,"PASS",date,"登录成功",GetExcelCells("C:\testcase", "login",i,7) Window("Flight Reservation").Close End If Next 订票流程功能脚本不但需要调用测试用例,并且在选择出发城市和到达城市时需要随机选择, 选择好出发城市和到达城市后,在选择航班时也需要做到随机选择,这样能更好地模拟真实的情况。 订票完成后需要检查订票信息是否已经写入数据库,即需要检查 Orders 表中是否添加了相关的订 单信息,增强后的脚本如下:
Dim errInfo '返回提示的错误信息 Dim flightcount '航班总数 Dim ordersinfo '订单号 Dim flag '标识订单是否在数据库中存在 flag = 0 For i=3 to GetExcleSheetRowsCount("C:\testcase","Tickets") BusinessName = GetExcelCells(ReadExcelPath,"Tickets",i,3) TestCaseID = GetExcelCells(ReadExcelPath,"Tickets",i,2) ReadString = GetExcelCells("C:\testcase","Tickets",i,6) arrExcelLines = Split(ReadString,",") systemutil.Run "C:\Program Files\HP\QuickTest Professional\samples\flight\app\flight4a.exe","","","" Call Login() wait(5) Window("Flight Reservation").ActiveX("MaskEdBox").Type arrExcelLines(0) '随机选择出发城市 Randomize randno = Int((9 * Rnd)) Window("Flight Reservation").WinComboBox("Fly From:").Select randno If Window("Flight Reservation").Dialog("Flight Reservations").Exist Then errInfo = Window("regexpwndtitle:=Flight Reservation").Dialog("text:=Flight Reservations"). Static("window id:=65535").GetROProperty("text") Window("Flight Reservation").Dialog("Flight Reservations").WinButton("确定").Click If errInfo = GetExcelCells("C:\testcase","Tickets",i,7) Then WriteHtml BusinessName,TestCaseID,"PASS",date,errInfo,GetExcelCells("C:\testcase", "Tickets",i,7) else WriteHtml BusinessName,TestCaseID,"FAIL",date,errInfo,GetExcelCells("C:\testcase", "Tickets",i,7) End If else '随机选择到达城市 Randomize randno = Int((9 * Rnd)) Window("Flight Reservation").WinComboBox("Fly To:").Select randno Window("Flight Reservation").WinButton("FLIGHT").Click flightcount = Window("Flight Reservation").Dialog("Flights Table").WinList("From").GetItemsCount '随机选择航班 Randomize randflight = Int(((flightcount-1)* Rnd)) Window("Flight Reservation").Dialog("Flights Table").WinList("From").Select randflight Window("Flight Reservation").Dialog("Flights Table").WinButton("OK").Click Window("Flight Reservation").WinEdit("Name:").Set arrExcelLines(1) Window("Flight Reservation").WinButton("Insert Order").Click wait(10) ordersinfo = Window("Flight Reservation").WinEdit("Order No:").GetROProperty("text") wait(5) call ConnectDatabase Rst.Open "select * from orders",Conn Do While Not Rst.EOF strDb=Rst.Fields.item(0) If strDb=info Then flag = flag + 1 WriteHtml BusinessName,TestCaseID,"PASS",date,"订票成功",GetExcelCells ("C:\testcase","Tickets",i,7) End If Rst.MoveNext Loop End If If flag=1 Then WriteHtml BusinessName,TestCaseID,"PASS",date,"订票成功",GetExcelCells("C:\testcase", "Tickets",i,7) else WriteHtml BusinessName,TestCaseID,"FAIL",date,"订票失败",GetExcelCells("C:\testcase", "Tickets",i,7) End If Window("Flight Reservation").Close Next 航班信息功能不需要读取数据,但需要随机选择出发城市和到达城市,当输入出发城市和到达 城市后,应该检查弹出的航班信息对话框中的所有航班信息是否成功,即是否与 Flights 表中的记 录对应,增强后的脚本如下: Dim flightinfo '显示所有航班信息 Dim flightcount '一共有多少次航班 Dim falg For i=0 to 5 systemutil.Run "C:\Program Files\HP\QuickTest Professional\samples\flight\app\flight4a.exe","","","" Call Login() wait(5) Window("Flight Reservation").ActiveX("MaskEdBox").Type "121212" Randomize randnoDeparturecity = Int((9 * Rnd)) Window("Flight Reservation").WinComboBox("Fly From:").Select randnoDeparturecity Departurecity = Window("Flight Reservation").WinComboBox("Fly From:").GetROProperty("text") '当选择了出发城市后,到达城市就只有 9 个,这样只要随机到 0~8 即可 Randomize randnoArrivalcity = Int((8 * Rnd)) Window("Flight Reservation").WinComboBox("Fly To:").Select randnoArrivalcity Arrivalcity = Window("Flight Reservation").WinComboBox("Fly To:").GetROProperty("text") Window("Flight Reservation").WinButton("Flight").Click Window("Flight Reservation").Dialog("Flights Table").WinList("From").Click flightinfo = Window("Flight Reservation").Dialog("Flights Table").WinList("From").GetROProperty ("all items") flightcount = Window("Flight Reservation").Dialog("Flights Table").WinList("From").GetItemsCount Call ConnectDatabas() Conn.Open StrConn sql = "select * from flights where Departure='"+Departurecity+"' and Arrival='"+Arrivalcity+"' and Day_Of_Week= 'Wednesday'" Rst.Open sql,Conn Do While Not Rst.EOF strDb=Rst.Fields.item(0) Pos = Instr(1, flightinfo, strDb, 1) msgbox Pos If Pos >0 Then falg = falg + 1 End If Rst.MoveNext Loop Window("Flight Reservation").Dialog("Flights Table").WinButton("OK").Click If falg = flightcount Then WriteHtml BusinessName,TestCaseID,"PASS",date,"航班信息正确",GetExcelCells ("C:\testcase","Airline",i,7) else WriteHtml BusinessName,TestCaseID,"FAIL",date,"航班信息错误",GetExcelCells ("C:\testcase","Airline",i,7) End If Window("Flight Reservation").Close Next 查询订票信息功能增强,即随机输入一个订单号,当该订单号存在时,需要进一步判断相关的 信息是否正确,如果正确,说明该测试通过,否则测试失败。增强后的脚本如下: systemutil.Run "C:\Program Files\HP\QuickTest Professional\samples\flight\app\flight4a.exe","","","" Call Login() Window("Flight Reservation").WinMenu("Menu").Select "File;Open Order..." Window("Flight Reservation").Dialog("Open Order").WinCheckBox("Order No.").Set "ON" Randomize orderno = Int((100 * Rnd)+1) Window("Flight Reservation").Dialog("Open Order").WinEdit("Edit").Set orderno Window("Flight Reservation").Dialog("Open Order").WinButton("OK").Click If Window("Flight Reservation").Dialog("Open Order").Dialog("Flight Reservations").Exist Then errInfo = Window("regexpwndtitle:=Flight Reservation").Dialog("text:=Open Order").Dialog ("regexpwndtitle:=Flight Reservations").Static("window id:=65535").GetROProperty("text") If errInfo=GetExcelCells("C:\testcase","Query",i,7) Then WriteHtml BusinessName,TestCaseID,"PASS",date,errInfo,GetExcelCells("C:\testcase","Query",i,7) else WriteHtml BusinessName,TestCaseID,"FAIL",date,errInfo,GetExcelCells("C:\testcase","Query",i,7) End If Window("Flight Reservation").Dialog("Open Order").Dialog("Flight Reservations").WinButton("确定").Click Window("Flight Reservation").Dialog("Open Order").Dialog("Flight Reservations").Close End If Call ConnectDatabase() sql="select * from orders where Order_Number ='"+orderno+"'" Rst.Open sql,Conn Do While Not Rst.EOF strDb=Rst.Fields.item(0) Window("Flight Reservation").Static("Order No:").GetROProperty("text") If Rst.Fields.item(0)=Window("Flight Reservation").Static("Order No:").GetROProperty("text") and Rst.Fields.item(1)= Window("Flight Reservation").Static("Name:").GetROProperty("text") and Rst.Fields. item(3)=Window("Flight Reservation"). Static("Flight No::").GetROProperty("text")ThenWriteHtml BusinessName,TestCaseID,"PASS",date,errInfo,GetExcelCells("C:\testcase","Query",i,7) Else WriteHtml BusinessName,TestCaseID,"FAIL",date,errInfo,GetExcelCells("C:\testcase","Query",i,7) End If Rst.MoveNext Loop Window("Flight Reservation").Close