天津工业大学实验指导书
时间: 年 月 日
课程名称:软件测试技术
实验名称:QTP检查点与脚本循环设计
班级: 姓名: 学号: 指导教师评定: 签名:
1 实验目的
(1)理解和掌握自动化测试的基本原理和方法。 (2)掌握QTP标准检查点的设置方法。
(3)掌握QTP动态捕捉信息与循环脚本的设计的方法。
2 实验要求
(1)使用QTP对订票程序的Insert order功能进行测试,验证订票是否成功。 (2)掌握在QTP中检查点的添加方法。
(3)使用QTP对被测程序进行动态信息捕捉的操作。 (4)掌握对测试脚本中取出多个值进行循环脚本的设计。
3 实验内容
(1)录制并生成订票脚本,按照三种方式来添加检查点,通过对update order按钮、delete order按钮、Insert Done按钮和Order No:文本框的属性进行验证,来判断订票是否成功;
(2)在订票脚本的基础上,通过设计循环脚本,动态取出“出发地”和“目的地”的所有航班,并测试程序是否正确。
4 实验步骤
(1)录制脚本:成功登陆订票窗口→在订票系统中输入航班日期→选择起飞地点→选择目的地→选择航班→输入顾客姓名→输入票的张数→选择航班级别→单击订票按钮;
(2)在日期栏输入 123112,选择起始和目的地点:Denver和Frankfurt,选择航班号15819,确定订单中的航班,输入订票姓名”zhangsan”,订票张数是2张,航班选择first,确定当前订票信息,单击”insert order”按钮。
(3)脚本录制完成后,脚本及订单图如下所示:
Dialog(\"Login\").WinEdit(\"Agent Name:\").Set \"test\" Dialog(\"Login\").WinEdit(\"Password:\").SetSecure \"4f669b9da99a7e76169a9134e948b20c8a2f4edc\" Dialog(\"Login\").WinButton(\"OK\").Click
Window(\"Flight Reservation\").WinMenu(\"Menu\").Select \"File;New Order\" Window(\"Flight Reservation\").ActiveX(\"MaskEdBox\").Type \"123112\"
1
Window(\"Flight Reservation\").WinComboBox(\"Fly From:\").Select \"Denver\" Window(\"Flight Reservation\").WinComboBox(\"Fly To:\").Select \"Frankfurt\" Window(\"Flight Reservation\").WinButton(\"FLIGHT\").Click
Window(\"Flight Reservation\").Dialog(\"Flights Table\").WinList(\"From\").Select \"15889 DEN 03:12 PM FRA 03:57 PM AA $104.10\"
Window(\"Flight Reservation\").Dialog(\"Flights Table\").WinButton(\"OK\").Click Window(\"Flight Reservation\").WinEdit(\"Name:\").Set \"zhangsan\" Window(\"Flight Reservation\").WinEdit(\"Tickets:\").Set \"2\" Window(\"Flight Reservation\").WinRadioButton(\"First\").Set Window(\"Flight Reservation\").WinButton(\"Insert Order\").Click
(4)回访脚本,检查脚本的正确性;
2
(5)在Active Screen中,用右键单击”Update Order”按钮,添加标准检查点,检查”Update Order”按钮的enabled属性值。如下图所示:
(6)点击OK按钮,打开checkpoint设置窗口,选择enabled属性,在Configure Value中,选择Constant,输入enabled属性的预期值为True,选”After current step”,点击“OK”,
3
如下图所示:
(7)增加完检查点后,脚本在keyword视图下,如下图所示:
(8)脚本在expert view下,如下所示:
Dialog(\"Login\").WinEdit(\"Agent Name:\").Set \"test\" Dialog(\"Login\").WinEdit(\"Password:\").SetSecure
4
\"4f669b9da99a7e76169a9134e948b20c8a2f4edc\" Dialog(\"Login\").WinButton(\"OK\").Click
Window(\"Flight Reservation\").WinMenu(\"Menu\").Select \"File;New Order\" Window(\"Flight Reservation\").ActiveX(\"MaskEdBox\").Type \"123112\"
Window(\"Flight Reservation\").WinComboBox(\"Fly From:\").Select \"Denver\" Window(\"Flight Reservation\").WinComboBox(\"Fly To:\").Select \"Frankfurt\" Window(\"Flight Reservation\").WinButton(\"FLIGHT\").Click
Window(\"Flight Reservation\").Dialog(\"Flights Table\").WinList(\"From\").Select \"15889 DEN 03:12 PM FRA 03:57 PM AA $104.10\"
Window(\"Flight Reservation\").Dialog(\"Flights Table\").WinButton(\"OK\").Click Window(\"Flight Reservation\").WinEdit(\"Name:\").Set \"zhangsan\" Window(\"Flight Reservation\").WinEdit(\"Tickets:\").Set \"2\" Window(\"Flight Reservation\").WinRadioButton(\"First\").Set Window(\"Flight Reservation\").WinButton(\"Insert Order\").Click
Window(\"Flight Reservation\").WinButton(\"Update Order\").Check CheckPoint(\"Update Order\")
(9)回放脚本,查看检查点的检查结果,测试报告是否显示为passed;
(10)在expert view下,将鼠标放置到 checkpoint(“update order”)上,右键点击鼠标,选择checkpoint properties,再次打开检查点属性设置窗口,选择enabled属性,在Configure Value中,选择Constant,输入enabled属性的预期值为False,如下图所示:
5
(11)重新回访脚本,查看此时的测试报告是否为Failed,并检查是否有出错的截图。
(12)对delete order按钮和Insert Done按钮按照以上的步骤,设置标准检查点,验证enabled属性是否为正确的值;
对delete order按钮当enable属性设置为false时,结果如下所示:
6
当对delete order按钮当enable属性设置为true时,结果如下所示:
对Insert Done按钮当enable属性设置为true时,结果如下所示:
7
对Insert Done按钮当enable属性设置为false时,结果如下所示:
(13)将下列取值,用循环脚本实现:
8
Dim Str_FlyFrom,Str_FlyTo,Str_Flight Dim Int_FlyFrom,Int_FlyTo,Int_Flight Dim i,j,k
Int_FlyFrom=Window(\"Flight Reservation\").WinComboBox(\"Fly From:\").GetItemsCount For i=0 to Int_FlyFrom-1
Str_FlyFrom = Window(\"Flight Reservation\").WinComboBox(\"Fly From:\").GetItem(i) Window(\"Flight Reservation\").WinComboBox(\"Fly From:\").Select Str_FlyFrom
Int_FlyTo = Window(\"Flight Reservation\").WinComboBox(\"Fly To:\").GetItemsCount For j=0 to Int_FlyTo-1
Str_FlyTo = Window(\"Flight Reservation\").WinComboBox(\"Fly To:\").GetItem(j) Window(\"Flight Reservation\").WinComboBox(\"Fly To:\").Select Str_FlyTo Window(\"Flight Reservation\").WinButton(\"FLIGHT\").Click Int_Flight = Window(\"Flight Reservation\").Dialog(\"Flights Table\").WinList(\"From\").GetItemsCount
For k=0 to Int_Flight-1 If k>0 Then
Window(\"Flight Reservation\").WinMenu(\"Menu\").Select \"File;New Order\" Window(\"FlightReservation\").ActiveX(\"MaskEdBox\").Type \"121212\"
Window(\"Flight Reservation\").WinComboBox(\"Fly From:\").Select Str_FlyFrom Window(\"Flight Reservation\").WinComboBox(\"Fly To:\").Select Str_FlyTo Window(\"Flight Reservation\").WinButton(\"FLIGHT\").Click Int_Flight=Window(\"FlightReservation\").Dialog(\"Flights Table\").WinList(\"From\").GetItemsCount
For k=0 to Int_Flight-1 Str_Flight = Window(\"Flight Reservation\").Dialog(\"Flights Table\").WinList(\"From\").GetItem(k)
Window(\"FlightReservation\").Dialog(\"Flights Table\").WinList(\"From\").Select Str_Flight Window(\"FlightReservation\").Dialog(\"Flights Table\").WinButton(\"OK\").Click Next Next Next
9
因篇幅问题不能全部显示,请点此查看更多更全内容