码迷,mamicode.com
首页 > 其他好文 > 详细

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

时间:2019-01-09 12:19:33      阅读:209      评论:0      收藏:0      [点我收藏+]

标签:大于   correct   static   qtp   env   开始   验证   mod   cfa   

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

有要用的话,自己改一下路径什么的。版本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

 

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

标签:大于   correct   static   qtp   env   开始   验证   mod   cfa   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!