qtp脚本测试飞机订票系统(代码)

嗯,以前没怎么研究过这个,最近做课设用到了,顺便发一下。

有要用的话,自己改一下路径什么的。版本qtp10.0

Mainaction

Dim AgentName

Dim Password

Dim DateOfFlight

Dim FaxNumber

Dim SelectTest

Dim DateOfUpdate

Dim DeleteName

Dimy

Dim e

Dim e

Datatable.ImportSheet "C:\Users\yue\Desktop\yuetest\excel\Main.xls","Sheet1","Main"

‘创建ExcelApp对象

Set ExcelApp=CreateObject("Excel.Application")

‘打开excel

Set ExcelWor=ExcelApp.Workbooks.Open("C:\Users\L\Desktop\Version1\excel\Main.xls")

‘这里需要用到UsedRange,表示Sheet1所使用单元格的范围,否则会将所有单元格都打印出

Set ExcelShe=ExcelWor.Worksheets("Sheet1").UsedRange

‘计算使用的单元格行数

rowcount=ExcelShe.Rows.count

‘计算使用的单元格的列数

columncount=ExcelShe.Columns.count

For x=1 to rowcount

y =1

AgentName = ExcelShe.Cells(x,y)

y= y+1

Password = ExcelShe.Cells(x,y)

y = y+1

DateOfFlight = ExcelShe.Cells(x,y)

y= y+1

FaxNumber = ExcelShe.Cells(x,y)

y= y+1

SearchTest = ExcelShe.Cells(x,y)

y = y+1

DateOfUpdate = ExcelShe.Cells(x,y)

j =y+1

DeleteName = ExcelShe.Cells(x,y)

u = 0

‘调用登录Action

SystemUtil.run "C:\Program Files (x86)\HP\QuickTest Professional\samples\flight\app\flight4a.exe"

RunAction "Login", oneIteration, AgentName, Password

e = DataTable.Value("Login","Global")

If e = "1" Then  RunAction "Book", oneIteration, DateOfFlight else u = 1 End If

e  = DataTable.Value("Book","Global")

If e = "1" Then  RunAction "Fax", oneIteration, FaxNumber End If

e  = DataTable.Value("Fax","Global")

If e = "1" Then  RunAction "Search", oneIteration, SearchTest, x  End If

e  = DataTable.Value("Search","Global")

If e = "1" Then  RunAction "Update", oneIteration, DateOfUpdate End If

e  = DataTable.Value("Update","Global")

If e = "1" Then  RunAction "Delete", oneIteration,DeleteName  End If

If u =0 Then Window("Flight Reservation").WinMenu("Menu").Select "File;Exit" End If

Next

Set ExcelShe=Nothing

‘关闭工作簿对象

ExcelWor.Close

‘退出ExcelApp对象

ExcelApp.Quit

Loginaction

Dim user

Dim pass

Datatable.ImportSheet " C:\Users\yue\Desktop\yuetest\excel\Login.xls","Sheet1","Login"

‘创建ExcelApp对象

Set ExcelApp=CreateObject("Excel.Application")

‘打开excel文件工作簿

Set ExcelWor=ExcelApp.Workbooks.Open("C:\Users\yue\Desktop\yuetest\excel\Login.xls")

‘这里需要用到UsedRange,表示Sheet1所使用单元格的范围,否则会将所有单元格都打印出

Set ExcelShe=ExcelWor.Worksheets("Sheet1").UsedRange

‘计算使用的单元格行数

rowcount=ExcelShe.Rows.count

‘计算使用的单元格的列数

columncount=ExcelShe.Columns.count

For i=1 to rowcount

For j=1 to columncount

‘获取单元格的内容

If j=1 Then  AgentName =ExcelShe.Cells(i,j)  Else Password = ExcelShe.Cells(i,j)  End If

Next

‘调用登录Action

SystemUtil.RUN "C:\Program Files (x86)\HP\QuickTest Professional\samples\flight\app\flight4a.exe"

RunAction "Login", oneIteration, AgentName, Password

If Window("Flight Reservation").Exist Then  Window("Flight Reservation").Close

Next

Set ExcelShe=Nothing

‘关闭工作簿对象

ExcelWor.Close

‘退出ExcelApp对象

ExcelApp.Quit

Login

Option explicit

Dim AgentName

Dim Password

Dim login

login  = 0

user = parameter("AgentName")

pass = parameter("Password")

Dialog("Login").WinEdit("Agent Name:").Set user

Dialog("Login").WinEdit("Agent Name:").Type  micTab

Dialog("Login").WinEdit("Password:").Set pass

Dialog("Login").WinButton("OK").Click

‘登录脚本实现参数化验证

If Dialog("Login").Dialog("Flight Reservations").Exist Then

If Dialog("Login").Dialog("Flight Reservations").Static("text:=Please enter agent name").Exist Then

Dialog("Login").Dialog("Flight Reservations").WinButton("确定").Click

Dialog("Login").WinButton("Cancel").Click

Reporter.ReportEvent micPass, "用户名不能为空"

elseIf Dialog("Login").Dialog("Flight Reservations").Static("text:=Agent name must be at least 4 characters long.").Exist Then

Dialog("Login").Dialog("Flight Reservations").WinButton("确定").Click

Dialog("Login").WinButton("Cancel").Click

Reporter.ReportEvent micPass, "用户名必须大于 4 个字符"

elseIf Dialog("Login").Dialog("Flight Reservations").Static("text:=Please enter password").Exist Then

Dialog("Login").Dialog("Flight Reservations").WinButton("确定").Click

Dialog("Login").WinButton("Cancel").Click

Reporter.ReportEvent micPass, "密码不能为空"

elseIf Dialog("Login").Dialog("Flight Reservations").Static("text:=Incorrect password. Please try again").Exist Then

Dialog("Login").Dialog("Flight Reservations").WinButton("确定").Click

Dialog("Login").WinButton("Cancel").Click

Reporter.ReportEvent micPass, "密码输入错误"

elseIf Dialog("Login").Dialog("Flight Reservations").Static("text:=Password must be at least 4 characters long").Exist Then

Dialog("Login").Dialog("Flight Reservations").WinButton("确定").Click

Dialog("Login").WinButton("Cancel").Click

Reporter.ReportEvent micPass, "密码必须大于 4 个字符"

else

Dialog("Login").Dialog("Flight Reservations").WinButton("确定").Click

Dialog("Login").WinButton("Cancel").Click

Reporter.ReportEvent micFail, "输入异常错误!!"

End If

else

login = 1

Reporter.ReportEvent micDone, "登录", "完成登录操作"

Reporter.ReportEvent micDone, "订票", "开始订票"

wait 2

End If

DataTable.Value("Login","Global") = login

 

Bookaction

Dim dingprq

Datatable.ImportSheet "C:\Users\yue\Desktop\yuetest\excel\Book.xls","Sheet1","Book"

‘创建ExcelApp对象

Set ExcelApp=CreateObject("Excel.Application")

‘打开excel文件工作簿

Set ExcelWor=ExcelApp.Workbooks.Open("C:\Users\yue\Desktop\yuetest\excel \Book.xls")

‘这里需要用到UsedRange,表示Sheet1所使用单元格的范围,否则会将所有单元格都打印出

Set ExcelShe=ExcelWor.Worksheets("Sheet1").UsedRange

‘计算使用的单元格行数

rowcount=ExcelShe.Rows.count

‘计算使用的单元格的列数

columncount=ExcelShe.Columns.count

For i=1 to rowcount

For j=1 to columncount

‘获取单元格的内容

dingprq =ExcelShe.Cells(i,j)

Next

‘调用订票Action

SystemUtil.run "C:\Program Files (x86)\HP\QuickTest Professional\samples\flight\app\flight4a.exe"

Dialog("Login").WinEdit("Agent Name:").Set "mercury"

Dialog("Login").WinEdit("Agent Name:").Type  micTab

Dialog("Login").WinEdit("Password:").Set "mercury"

Dialog("Login").WinButton("OK").Click

RunAction "Book", oneIteration, DateOfFlight

Window("Flight Reservation").WinMenu("Menu").Select "File;Exit"

Next

Set ExcelShe=Nothing

‘关闭工作簿对象

ExcelWor.Close

‘退出ExcelApp对象

ExcelApp.Quit

Book

Option explicit

Dim dingprq

dingprq = parameter("DateOfFlight")

Dim  book

book  = 0

Window("Flight Reservation").WinObject("Date of Flight:").Type dingprq

Window("Flight Reservation").WinComboBox("Fly From:").Select "Frankfurt"

‘订票脚本实现参数化验证

If Window("Flight Reservation").Dialog("Flight Reservations").Exist Then

If Window("Flight Reservation").Dialog("Flight Reservations").Static("text:=Valid flight dates are after 01/02/19").Exist Then                         ‘日期变化

Window("Flight Reservation").Dialog("Flight Reservations").WinButton("确定").Click

Reporter.ReportEvent micPass, "订票日期必须为当前日期(含)之后"

‘月份错误

elseIf Window("Flight Reservation").Dialog("Flight Reservations").Static("text:=Invalid month Entered.The month must be greater than 01 and less than 12.").Exist Then

Window("Flight Reservation").Dialog("Flight Reservations").WinButton("确定").Click

Reporter.ReportEvent micPass, "订票月份必须大于01且小于12"

‘日期错误

elseIf Window("Flight Reservation").Dialog("Flight Reservations").Static("text:=Invalid day Entered. The date should be valid for the given month.").Exist Then

Window("Flight Reservation").Dialog("Flight Reservations").WinButton("确定").Click

Reporter.ReportEvent micPass, "订票日期必须对给定月份有效"

‘未输入

elseIf Window("Flight Reservation").Dialog("Flight Reservations").Static("text:=Please enter a flight date.").Exist Then

Window("Flight Reservation").Dialog("Flight Reservations").WinButton("确定").Click

Reporter.ReportEvent micPass, "未输入航班日期"

‘年份错误

elseIf Window("Flight Reservation").Dialog("Flight Reservations").Static("text:=Invalid year Entered. " + chr(10) + "The year must be greater than 2019" + chr(10) + "and less than 2038.").Exist Then

Window("Flight Reservation").Dialog("Flight Reservations").WinButton("确定").Click

‘Window("Flight Reservation").WinMenu("Menu").Select "File;Exit"

Reporter.ReportEvent micPass, "订票年份必须大于2019且小于2038"

else

Window("Flight Reservation").Dialog("Flight Reservations").WinButton("确定").Click

Reporter.ReportEvent micFail, "输入异常错误!!"

End If

else

book = 1

Window("Flight Reservation").WinComboBox("Fly To:").Select "Denver"

Window("Flight Reservation").WinButton("FLIGHT").Click

Window("Flight Reservation").Dialog("Flights Table").WinList("From").Activate "17707   FRA   03:48 PM   DEN   04:31 PM   AA     $111.00"

Window("Flight Reservation").WinEdit("Name:").Set "Dylan"

Window("Flight Reservation").WinEdit("Tickets:").Set "3"

Window("Flight Reservation").WinRadioButton("First").Set

Window("Flight Reservation").WinButton("Insert Order").Click

Reporter.ReportEvent micDone, "订票", "完成订票操作"

Reporter.ReportEvent micDone, "传真", "开始传真"

wait 2

End If

DataTable.Value("Book","Global") =  book

Faxaction

Dim chuanzh

Datatable.ImportSheet " C:\Users\yue\Desktop\yuetest\excel \Fax.xls","Sheet1","Fax"

‘创建ExcelApp对象

Set ExcelApp=CreateObject("Excel.Application")

‘打开excel文件工作簿

Set ExcelWor=ExcelApp.Workbooks.Open("C:\Users\yue\Desktop\yuetest\excel \Fax.xls")

‘这里需要用到UsedRange,表示Sheet1所使用单元格的范围,否则会将所有单元格都打印出

Set ExcelShe=ExcelWor.Worksheets("Sheet1").UsedRange

‘计算使用的单元格行数

rowcount=ExcelShe.Rows.count

‘计算使用的单元格的列数

columncount=ExcelShe.Columns.count

For i=1 to rowcount

For j=1 to columncount

‘获取单元格的内容

FaxNumber =ExcelShe.Cells(i,j)

Next

‘调用传真Action

SystemUtil.run "C:\Program Files (x86)\HP\QuickTest Professional\samples\flight\app\flight4a.exe"

Dialog("Login").WinEdit("Agent Name:").Set "mercury"

Dialog("Login").WinEdit("Agent Name:").Type  micTab

Dialog("Login").WinEdit("Password:").Set "mercury"

Dialog("Login").WinButton("OK").Click

RunAction "Fax", oneIteration, FaxNumber

Window("Flight Reservation").WinMenu("Menu").Select "File;Exit"

Next

Set ExcelShe=Nothing

‘关闭工作簿对象

ExcelWor.Close

‘退出ExcelApp对象

ExcelApp.Quit

Fax

Option explicit

Dim chuanzh

Dim  fax

fax = 0

chuanzh = parameter("FaxNumber")

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 "11"

Window("Flight Reservation").Dialog("Open Order").WinButton("OK").Click

Window("Flight Reservation").WinMenu("Menu").Select "File;Fax Order..."

Window("Flight Reservation").Dialog("Fax Order No. 11").WinObject("Fax Number:").Type FaxNumber

Window("Flight Reservation").Dialog("Fax Order No. 11").WinButton("Send").Click

‘传真脚本实现参数化验证

If Window("Flight Reservation").Dialog("Fax Order No. 11").Dialog("Flight Reservations").Exist Then

If Window("Flight Reservation").Dialog("Fax Order No. 11").Dialog("Flight Reservations").Static("text:=Please complete the fax number.").Exist Then

Window("Flight Reservation").Dialog("Fax Order No. 11").Dialog("Flight Reservations").WinButton("确定").Click

Window("Flight Reservation").Dialog("Fax Order No. 11").WinButton("Cancel").Click

Reporter.ReportEvent micPass, "传真号码错误"

else

Window("Flight Reservation").Dialog("Flight Reservations").WinButton("确定").Click

Reporter.ReportEvent micFail, "输入异常错误!!"

End If

else

fax = 1

Reporter.ReportEvent micDone, "传真", "完成传真操作"

Reporter.ReportEvent micDone, "查询", "开始查询"

wait 2

End If

DataTable.Value("Fax","Global") = fax

Searchaction

Dim SearchTest

Datatable.ImportSheet " C:\Users\yue\Desktop\yuetest\excel \Search.xls","Sheet1","Search"

‘创建ExcelApp对象

Set ExcelApp=CreateObject("Excel.Application")

‘打开excel文件工作簿

Set ExcelWor=ExcelApp.Workbooks.Open("C:\Users\yue\Desktop\yuetest\excel \Search.xls")

‘这里需要用到UsedRange,表示Sheet1所使用单元格的范围,否则会将所有单元格都打印出

Set ExcelShe=ExcelWor.Worksheets("Sheet1").UsedRange

‘计算使用的单元格行数

rowcount=ExcelShe.Rows.count

‘计算使用的单元格的列数

columncount=ExcelShe.Columns.count

For i=1 to rowcount

For j=1 to columncount

‘获取单元格的内容

SearchTest =ExcelShe.Cells(i,j)

Next

SystemUtil.run "C:\Program Files (x86)\HP\QuickTest Professional\samples\flight\app\flight4a.exe"

Dialog("Login").WinEdit("Agent Name:").Set "mercury"

Dialog("Login").WinEdit("Agent Name:").Type  micTab

Dialog("Login").WinEdit("Password:").Set "mercury"

Dialog("Login").WinButton("OK").Click

‘调用查找Action

RunAction "Search", oneIteration, SearchTest, i

Window("Flight Reservation").WinMenu("Menu").Select "File;Exit"

Next

Set ExcelShe=Nothing

‘关闭工作簿对象

ExcelWor.Close

‘退出ExcelApp对象

ExcelApp.Quit

Search

Option explicit

Dim SearchTest

Dim SearchNum

Dim search

search = 0

SearchTest = parameter("SearchTest")

SearchNum = parameter("SearchNum")

Window("Flight Reservation").WinMenu("Menu").Select "File;Open Order..."

If SearchNum MOD 3 = 1 Then

Window("Flight Reservation").Dialog("Open Order").WinCheckBox("Customer Name").Set "ON"

Window("Flight Reservation").Dialog("Open Order").WinEdit("Edit").Set SearchTest

elseIf SearchNum MOD 3 = 2 Then

Window("Flight Reservation").Dialog("Open Order").WinCheckBox("Flight Date").Set "ON"

Window("Flight Reservation").Dialog("Open Order").WinObject("23/22/3_").Type SearchTest

else

Window("Flight Reservation").Dialog("Open Order").WinCheckBox("Order No.").Set "ON"

Window("Flight Reservation").Dialog("Open Order").WinEdit("Edit_2").Set SearchTest

End If

Window("Flight Reservation").Dialog("Open Order").WinButton("OK").Click

‘查询脚本实现参数化验证

If Window("Flight Reservation").Dialog("Open Order").Dialog("Flight Reservations").Exist Then

If Window("Flight Reservation").Dialog("Open Order").Dialog("Flight Reservations").Static("text:=No orders found. Please try again").Exist Then

Window("Flight Reservation").Dialog("Open Order").Dialog("Flight Reservations").WinButton("确定").Click

Window("Flight Reservation").Dialog("Open Order").WinButton("Cancel").Click

Reporter.ReportEvent micPass, "没有找到包含顾客名字的订单"

elseIf Window("Flight Reservation").Dialog("Open Order").Dialog("Flight Reservations").Static("text:=Invalid year Entered. The year must be greater than 1970 and less than 2038.").Exist Then

Window("Flight Reservation").Dialog("Open Order").Dialog("Flight Reservations").WinButton("确定").Click

Window("Flight Reservation").Dialog("Open Order").WinButton("Cancel").Click

Reporter.ReportEvent micPass, "订票年份必须大于1970年且不到2038年"

elseIf Window("Flight Reservation").Dialog("Open Order").Dialog("Flight Reservations").Static("text:=Invalid month Entered.The month must be greater than 01 and less than 12.").Exist Then

Window("Flight Reservation").Dialog("Open Order").Dialog("Flight Reservations").WinButton("确定").Click

Window("Flight Reservation").Dialog("Open Order").WinButton("Cancel").Click

Reporter.ReportEvent micPass, "订票月份必须大于01且小于12"

elseIf Window("Flight Reservation").Dialog("Open Order").Dialog("Flight Reservations").Static("text:=Invalid day Entered. The date should be valid for the given month.").Exist Then

Window("Flight Reservation").Dialog("Open Order").Dialog("Flight Reservations").WinButton("确定").Click

Window("Flight Reservation").Dialog("Open Order").WinButton("Cancel").Click

Reporter.ReportEvent micPass, "订票日期必须对给定月份有效"

elseIf Window("Flight Reservation").Dialog("Open Order").Dialog("Flight Reservations").Static("text:=Order number " + SearchTest + " does not exist").Exist Then

Window("Flight Reservation").Dialog("Open Order").Dialog("Flight Reservations").WinButton("确定").Click

Window("Flight Reservation").Dialog("Open Order").WinButton("Cancel").Click

Reporter.ReportEvent micPass,"失败测试","订单号不存在"

else

Window("Flight Reservation").Dialog("Open Order").Dialog("Flight Reservations").WinButton("确定").Click

Window("Flight Reservation").Dialog("Open Order").WinButton("Cancel").Click

Reporter.ReportEvent micFail,"输入异常","输入异常错误!!"

End If

elseIf SearchNum MOD 3 = 1 OR SearchNum MOD 3 = 2 Then Window("Flight Reservation").Dialog("Open Order").Dialog("Search Results").WinButton("OK").Click

search = 1

Reporter.ReportEvent micDone, "查询", "完成查询操作"

Reporter.ReportEvent micDone, "更新", "开始更新"

wait 2

End If

DataTable.Value("Search","Global") = search

Updateaction

Dim DateOfUpdate

Datatable.ImportSheet " C:\Users\yue\Desktop\yuetest\excel \Update.xls","Sheet1","Update"

‘创建ExcelApp对象

Set ExcelApp=CreateObject("Excel.Application")

‘打开excel文件工作簿

Set ExcelWor=ExcelApp.Workbooks.Open("C:\Users\yue\Desktop\yuetest\excel \Update.xls")

‘这里需要用到UsedRange,表示Sheet1所使用单元格的范围,否则会将所有单元格都打印出

Set ExcelShe=ExcelWor.Worksheets("Sheet1").UsedRange

‘计算使用的单元格行数

rowcount=ExcelShe.Rows.count

‘计算使用的单元格的列数

columncount=ExcelShe.Columns.count

For i=1 to rowcount

For j=1 to columncount

‘获取单元格的内容

DateOfUpdate =ExcelShe.Cells(i,j)

Next

SystemUtil.run "C:\Program Files (x86)\HP\QuickTest Professional\samples\flight\app\flight4a.exe"

Dialog("Login").WinEdit("Agent Name:").Set "mercury"

Dialog("Login").WinEdit("Agent Name:").Type  micTab

Dialog("Login").WinEdit("Password:").Set "mercury"

Dialog("Login").WinButton("OK").Click

‘调用更新Action

RunAction "Update", oneIteration, DateOfUpdate

Window("Flight Reservation").WinMenu("Menu").Select "File;Exit"

Next

Set ExcelShe=Nothing

‘关闭工作簿对象

ExcelWor.Close

‘退出ExcelApp对象

ExcelApp.Quit

Update

Option explicit

Dim DateOfUpdate

Dim update

update = 0

DateOfUpdate = parameter("DateOfUpdate")

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 "11"

Window("Flight Reservation").Dialog("Open Order").WinButton("OK").Click

Window("Flight Reservation").WinObject("Date of Flight:").Type  micDel

Window("Flight Reservation").WinObject("Date of Flight:").Type  micDel

Window("Flight Reservation").WinObject("Date of Flight:").Type  micDel

Window("Flight Reservation").WinObject("Date of Flight:").Type  micDel

Window("Flight Reservation").WinObject("Date of Flight:").Type  micDel

Window("Flight Reservation").WinObject("Date of Flight:").Type  micDel

Window("Flight Reservation").WinObject("Date of Flight:").Type DateOfUpdate

Window("Flight Reservation").WinButton("FLIGHT").Click

‘更新脚本实现参数化验证

If Window("Flight Reservation").Dialog("Flight Reservations").Exist Then

If Window("Flight Reservation").Dialog("Flight Reservations").Static("text:=Valid flight dates are after 01/03/19").Exist Then                         ‘日期变化

Window("Flight Reservation").Dialog("Flight Reservations").WinButton("确定").Click

Reporter.ReportEvent micPass,"失败测试","订票日期必须为当前日期(含)之后"

‘年份错误

elseIf Window("Flight Reservation").Dialog("Flight Reservations").Static("text:=Invalid year Entered. " + chr(10) + "The year must be greater than 2019" + chr(10) + "and less than 2038.").Exist Then

Window("Flight Reservation").Dialog("Flight Reservations").WinButton("确定").Click

Reporter.ReportEvent micPass, "订票年份必须大于2019且小于2038"

‘月份错误

elseIf Window("Flight Reservation").Dialog("Flight Reservations").Static("text:=Invalid month Entered.The month must be greater than 01 and less than 12.").Exist Then

Window("Flight Reservation").Dialog("Flight Reservations").WinButton("确定").Click

Reporter.ReportEvent micPass, "订票月份必须大于01且小于12"

‘日期错误

elseIf Window("Flight Reservation").Dialog("Flight Reservations").Static("text:=Invalid day Entered. The date should be valid for the given month.").Exist Then

Window("Flight Reservation").Dialog("Flight Reservations").WinButton("确定").Click

Reporter.ReportEvent micPass, "订票日期必须对给定月份有效"

‘未输入

elseIf Window("Flight Reservation").Dialog("Flight Reservations").Static("text:=Please enter a flight date.").Exist Then

Window("Flight Reservation").Dialog("Flight Reservations").WinButton("确定").Click

Reporter.ReportEvent micPass, "未输入航班日期"

else

Window("Flight Reservation").Dialog("Flight Reservations").WinButton("确定").Click

Reporter.ReportEvent micFail, "输入异常错误!!"

End If

else

Window("Flight Reservation").Dialog("Flights Table").WinButton("OK").Click

Window("Flight Reservation").WinButton("Update Order").Click

‘未修改

If Window("Flight Reservation").Dialog("Flight Reservations").Static("text:=Record not updated; No Field values set").Exist Then

Window("Flight Reservation").Dialog("Flight Reservations").WinButton("确定").Click

Reporter.ReportEvent micPass, "没有记录被更新"

End If

update = 1

Reporter.ReportEvent micDone, "完成更新操作"

Reporter.ReportEvent micDone, "开始删除"

wait 2

End If

DataTable.Value("Update","Global") = update

Deleteaction

Dim DeleteName

Datatable.ImportSheet " C:\Users\yue\Desktop\yuetest\excel \Delete.xls","Sheet1","Delete"

‘创建ExcelApp对象

Set ExcelApp=CreateObject("Excel.Application")

‘打开excel文件工作簿

Set ExcelWor=ExcelApp.Workbooks.Open("C:\Users\L\Desktop\Version1\excel\Delete.xls")

‘这里需要用到UsedRange,表示Sheet1所使用单元格的范围,否则会将所有单元格都打印出

Set ExcelShe=ExcelWor.Worksheets("Sheet1").UsedRange

‘计算使用的单元格行数

rowcount=ExcelShe.Rows.count

‘计算使用的单元格的列数

columncount=ExcelShe.Columns.count

For i=1 to rowcount

For j=1 to columncount

‘获取单元格的内容

DeleteName =ExcelShe.Cells(i,j)

Next

SystemUtil.run "C:\Program Files (x86)\HP\QuickTest Professional\samples\flight\app\flight4a.exe"

Dialog("Login").WinEdit("Agent Name:").Set "mercury"

Dialog("Login").WinEdit("Agent Name:").Type  micTab

Dialog("Login").WinEdit("Password:").Set "mercury"

Dialog("Login").WinButton("OK").Click

‘调用删除Action

RunAction "Delete", oneIteration, DeleteName

Window("Flight Reservation").WinMenu("Menu").Select "File;Exit"

Next

Set ExcelShe=Nothing

‘关闭工作簿对象

ExcelWor.Close

‘退出ExcelApp对象

ExcelApp.Quit

Delete

Option explicit

Dim DeleteName

Dim del

del = 0

DeleteName = parameter("DeleteName")

Window("Flight Reservation").WinMenu("Menu").Select "File;Open Order..."

If Window("Flight Reservation").Dialog("Flight Reservations").Exist Then

Window("Flight Reservation").Dialog("Flight Reservations").WinButton("否(N)").Click

End If

Window("Flight Reservation").Dialog("Open Order").WinCheckBox("Customer Name").Set "ON"

Window("Flight Reservation").Dialog("Open Order").WinEdit("Edit").Set DeleteName

Window("Flight Reservation").Dialog("Open Order").WinButton("OK").Click

‘删除脚本实现参数化验证

If Window("Flight Reservation").Dialog("Open Order").Dialog("Flight Reservations").Exist Then

If Window("Flight Reservation").Dialog("Open Order").Dialog("Flight Reservations").Static("text:=No orders found. Please try again").Exist Then

Window("Flight Reservation").Dialog("Open Order").Dialog("Flight Reservations").WinButton("确定").Click

Window("Flight Reservation").Dialog("Open Order").WinButton("Cancel").Click

Reporter.ReportEvent micPass, "没有找到包含顾客名字的订单"

else

Window("Flight Reservation").Dialog("Open Order").Dialog("Flight Reservations").WinButton("确定").Click

Window("Flight Reservation").Dialog("Open Order").WinButton("Cancel").Click

Reporter.ReportEvent micFail, "输入异常错误!!"

End If

else

Window("Flight Reservation").Dialog("Open Order").Dialog("Search Results").WinButton("OK").Click

Window("Flight Reservation").WinButton("Delete Order").Click

Window("Flight Reservation").Dialog("Flight Reservations").WinButton("是(Y)").Click

del = 1

Reporter.ReportEvent micDone, "完成删除操作"

Reporter.ReportEvent micDone, "已经完成"

wait 2

End If

DataTable.Value("Del","Global") = del

原文地址:https://www.cnblogs.com/gongzixi/p/10243449.html

时间: 2024-10-06 21:08:34

qtp脚本测试飞机订票系统(代码)的相关文章

web类协议脚本-飞机订票系统示例

以下是LR自带的飞机订票系统的Demo,希望能帮助大家. Action() { int iRand; int iTmp; char *strTmpA; char *strTmpB; char *strTmpC; char *position; if ((strTmpA = (char *)malloc(100 * sizeof(char))) == NULL) { lr_output_message ("Insufficient memory available"); return -

windows API 开发飞机订票系统 图形化界面 (四)

接下来的是录入航班.修改航班信息功能的实现: 1 //录入航班 2 BOOL EntryFlight(HWND hEntryDlg){ 3 4 TCHAR szDiscount[16]; 5 TCHAR szFare[16],szSeat_Number[16]; 6 TCHAR szFlight_Number[16], szDate[16]; 7 TCHAR szDeparture[16], szDestination[16]; 8 TCHAR szTakeOff_Time[16], szLan

飞机订票系统

飞机订票系统 // 飞机订票系统.cpp : 定义控制台应用程序的入口点. // #include "stdafx.h" #include <stdio.h> #include <string.h> #include<stdlib.h> #include<conio.h> #define N 2 typedef struct plane { char ID[10]; char Start_Place[10]; char End_Place

windows API 开发飞机订票系统 图形化界面 (三)

来吧,接下来是各个功能的函数的实现代码. 首先,程序运行时加载读入账户信息和航班信息.接下来就该读取文件了. 我把账户资料和航班信息储存在了.txt文件里 那么问题就来了,挖掘机...额,不对,应该怎么读入账户资料和航班信息? 每一行是结构体的一个成员,我读入的方式是一行一行读入. 两个读入函数代码如下: 1 //读入账户信息 2 BOOL ReadAccountData(HWND hwndDlg){ 3 4 FILE *fp; 5 6 passenger = (Passenger *)mall

C语言实现-航空订票系统(飞机订票系统)

开发环境:CodeBlocks 开发语言:C 实现功能:登录,订票,退票 数据存储:文本读写 涉及文件: ? 相关文件下载: 码云:https://gitee.com/ikaros-521/c_project/tree/master/%E9%A3%9E%E6%9C%BA%E8%AE%A2%E7%A5%A8%E7%B3%BB%E7%BB%9F%EF%BC%88%E8%88%AA%E7%A9%BA%E8%AE%A2%E7%A5%A8%E7%B3%BB%E7%BB%9F%EF%BC%89 程序主界面:

UTF简单脚本录制(飞机订票系统)

1.直接录制脚本-文件-新建-测试-GUI-创建 2.录制配置-添加程序路径 3.录制-输入用户名密码.机票事件地点.查询航班情况.登机人,提交 Dialog("Login").WinEdit("Agent Name:").SetSelection 0,6 Dialog("Login").WinEdit("Agent Name:").Set "dfsdf" Dialog("Login")

课程设计之(struts2+Hibernate)航空订票系统

1.题目 课程设计之航空订票系统 为某家机票预订服务商开发一个机票预订和查询管理系统.该系统中的航班和机票信息由多家航空公司负责提供.客户通过上网方式查询航班时间表.机票可用信息.机票折扣信息,可以远程订票.退票.通过信用卡支付票款.客户分为三类:金牌客户.银牌客户和普通客户.普通客户通过订票积分至一定的额度可以逐步升级为银牌客户.金牌客户.不同类别的客户可享有不同的机票折扣.系统还必须每日.每周.每月给出机票销售的统计分析报表. l         实验要求: 按基于数据流的软件工程的要求完成

关于铁路订票系统如何改善设计的讨论

由12306.cn谈谈网站性能技术 铁路订票系统的简单设计

【C语言】火车订票系统

#include<stdio.h> #include<string.h> #include<iostream> #include<process.h> #include<conio.h> #include<iomanip> #define max 60 typedef struct customer {//乘客信息 char name[10];//姓名 int  amount;//订票数 char rank;//火车票种类:硬座.软座