概述
针对flight4a,及以上2个功能:登入与订票,本文末尾有操作视频可下载观看,实在无法测试、不理解的可以按视频操作
题目要求
1、使用数据驱动脚本/结构化脚本两种方式,测试飞机订票系统,证明使用4-10位的用户名就可以正常登陆
数据驱动:
systemutil.Run "D:Downloadflightappflight4b.exe"
Dialog("Login").WinEdit("Agent Name:").Set DataTable("p_mode", dtGlobalSheet)
Dialog("Login").WinEdit("Password:").SetSecure "5b081dd06174ee3f2423c425a337715e7796b92f"
Dialog("Login").WinButton("OK").Click
Window("Flight Reservation_2").Close
p_mode内的值
结构化:
Dim str,i
i=4
str="123"
do while i<=10
systemutil.Run "D:Downloadflightappflight4b.exe"
str=str&i
Dialog("Login").WinEdit("Agent Name:").Set str
wait 1
Dialog("Login").WinEdit("Password:").SetSecure "5b081dd06174ee3f2423c425a337715e7796b92f" '密码:mercury
Dialog("Login").WinButton("OK").Click
Window("Flight Reservation_2").Close
i=i+1
loop
2、使用结构化脚本订购明天、后天、大后天的机票,随机地点、时间随机
Dim i,v_date,v_year,v_month,v_day,str,count,v_rnd
str=""
For i = 1 To 3
msgbox i
v_date=date+1
v_year=mid(year(v_date),3)
v_month=month(v_date)
If v_month<10 Then
v_month="0"&v_month
End If
v_day=day(v_date)
If v_day<10 Then
v_day="0"&v_day
End If
str=v_month&v_day&v_year
msgbox str
wait 1
Window("Flight Reservation").ActiveX("MaskEdBox").Type str
count=Window("Flight Reservation").WinComboBox("Fly From:").getitemscount
v_rnd=randomnumber.Value(0,count)
Window("Flight Reservation").WinComboBox("Fly From:").Select v_rnd
count=Window("Flight Reservation").WinComboBox("Fly To:").getitemscount
v_rnd=randomnumber.Value(0,count)
Window("Flight Reservation").WinComboBox("Fly To:").Select v_rnd
Window("Flight Reservation").WinButton("FLIGHT").Click
Window("Flight Reservation").Dialog("Flights Table").WinButton("OK").Click
Window("Flight Reservation").WinEdit("Name:").Set i
Window("Flight Reservation").WinButton("Insert Order").Click
Window("Flight Reservation").WinMenu("Menu").Select "File;New Order"
Next
3、在上一题的基础,每天添加订购人,订购人为Jim,LiLy,Lucy每人各2、3、4张票
Dim i,v_date,v_year,v_month,v_day,str,count,v_rnd,v_name
str=""
For i = 2 To 4
msgbox i
v_date=date+1
v_year=mid(year(v_date),3)
v_month=month(v_date)
If v_month<10 Then
v_month="0"&v_month
End If
v_day=day(v_date)
If v_day<10 Then
v_day="0"&v_day
End If
str=v_month&v_day&v_year
msgbox str
wait 1
Window("Flight Reservation").ActiveX("MaskEdBox").Type str
count=Window("Flight Reservation").WinComboBox("Fly From:").getitemscount
v_rnd=randomnumber.Value(0,count)
Window("Flight Reservation").WinComboBox("Fly From:").Select v_rnd
count=Window("Flight Reservation").WinComboBox("Fly To:").getitemscount
v_rnd=randomnumber.Value(0,count)
Window("Flight Reservation").WinComboBox("Fly To:").Select v_rnd
Window("Flight Reservation").WinButton("FLIGHT").Click
Window("Flight Reservation").Dialog("Flights Table").WinButton("OK").Click
select case(i)
Case 2
v_name="Jim"
Case 3
v_name="LiLy"
Case 4
v_name="Lucy"
Case else
v_name="other"
End select
Window("Flight Reservation").WinEdit("Name:").Set v_name
Window("Flight Reservation").WinEdit("Tickets:").Set i
Window("Flight Reservation").WinButton("Insert Order").Click
Window("Flight Reservation").WinMenu("Menu").Select "File;New Order"
Next
4、在上一题的基础上,添加分别购买头等舱、经济舱、商务舱
Dim i,v_date,v_year,v_month,v_day,str,count,v_rnd,v_name
str=""
For i = 2 To 4
msgbox i
v_date=date+1
v_year=mid(year(v_date),3)
v_month=month(v_date)
If v_month<10 Then
v_month="0"&v_month
End If
v_day=day(v_date)
If v_day<10 Then
v_day="0"&v_day
End If
str=v_month&v_day&v_year
msgbox str
wait 1
Window("Flight Reservation").ActiveX("MaskEdBox").Type str
count=Window("Flight Reservation").WinComboBox("Fly From:").getitemscount
v_rnd=randomnumber.Value(0,count)
Window("Flight Reservation").WinComboBox("Fly From:").Select v_rnd
count=Window("Flight Reservation").WinComboBox("Fly To:").getitemscount
v_rnd=randomnumber.Value(0,count)
Window("Flight Reservation").WinComboBox("Fly To:").Select v_rnd
Window("Flight Reservation").WinButton("FLIGHT").Click
Window("Flight Reservation").Dialog("Flights Table").WinButton("OK").Click
select case(i)
Case 2
v_name="Jim"
Case 3
v_name="LiLy"
Case 4
v_name="Lucy"
Case else
v_name="other"
End select
Window("Flight Reservation").WinEdit("Name:").Set v_name
wait 1
Window("Flight Reservation").WinEdit("Tickets:").Set i
select case(i)
Case 2
Window("Flight Reservation").WinRadioButton("First").Set
Case 3
Window("Flight Reservation").WinRadioButton("Business").Set
Case 4
Window("Flight Reservation").WinRadioButton("Economy").Set
Case else
End select
wait 1
Window("Flight Reservation").WinButton("Insert Order").Click
Window("Flight Reservation").WinMenu("Menu").Select "File;New Order"
Next
视频下载地址:https://download.csdn.net/download/u010746293/10438669
ps:QTP语法大部分可以参考VB但不是全部
最后
以上就是内向荷花为你收集整理的UFT12(QTP)自动化测试 -相关练习的全部内容,希望文章能够帮你解决UFT12(QTP)自动化测试 -相关练习所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复