QTP测试多个Windows应用程序的解决方案
来源:互联网 发布:新型网络传销模式 编辑:程序博客网 时间:2024/05/16 03:06
relevantcodes.com的《QTP: Working With Multiple Windows Applications》这篇文章介绍了如何测试多个相同Windows应用程序的方法:
http://relevantcodes.com/qtp-working-with-multiple-windows-applications/
其核心思想是把出现的窗口句柄存到数组中,并给窗口一个指定的名字,这样后面访问窗口对象时,只要指定名字就可以了。
核心类colWindows封装在名为clsWindow.qfl的函数库文件中,主要由以下函数组成:
LaunchAdd: Launch a new window and retain its reference throughout the test cycle
AddNew: Automatically add a new open window to the collection without you having to specify its properties (see list of dependencies)
AddCustom: Adds a custom window by specifying its properties as an array
使用例子如下所示(其中WindowObject就是由colWindows类产生的对象):
'Please make sure the library file (clsWindow.qfl) is associated with the test.
'clsWindow.qfl is located in the test's directly: /clsWindow95Demo/clsWindow.qfl
'=================================
'============================================
'LaunchAdd
'============================================
'Open the AUT and add it to our collection as "Flight1"
'If using 9.2 and below:
WindowObject.LaunchAdd "C:/Program Files/HP/QuickTest Professional/samples/flight/app/flight4a.exe", "Flight1"
'If using 9.5 and higher:
'WindowObject.LaunchAdd "C:/Program Files/HP/QuickTest Professional/samples/flight/app/flight4a.exe", "Flight1"
'Use the reference we gave in the previous statement (Flight1):
With WindowObject.Name("Flight1")
.WinEdit("attached text:=Agent Name:").Set "mercury"
.WinEdit("attached text:=Password:").Set "mercury"
.WinButton("text:=OK").Click
End With
'============================================
'AddCustom
'============================================
MsgBox "Demonstrating AddCustom: It will add the windows, whose properties we specify through an array."
'Add a custom window by specifying its description as FlightReservation2
WindowObject.AddCustom Array("regexpwndtitle:=Flight Reservation", "index:=1"), "FlightReservation2"
With WindowObject.Name("FlightReservation2")
.Highlight
.WinObject("attached text:=Date of Flight:", "index:=0").Type "09/09/12"
.WinComboBox("attached text:=Fly From:", "index:=0").Select "Denver"
.WinComboBox("attached text:=Fly To:", "index:=0").Select "Frankfurt"
.WinButton("text:=FLIGHT").Click
End With
Dialog("micclass:=Dialog").WinButton("text:=OK").Click
With WindowObject.Name("FlightReservation2")
.WinEdit("attached text:=Name:", "index:=0").Type "Relevant Codes 2"
.WinButton("text:=&Insert Order").Click
.WinObject("nativeclass:=AfxWnd40").WaitProperty "regexpwndtitle", "Insert Done...", 30000
End with
'============================================
'LaunchAdd
'============================================
'Open another instance of our AUT and add it to our collection as "Flight2"
'If using 9.2 and below:
WindowObject.LaunchAdd "C:/Program Files/HP/QuickTest Professional/samples/flight/app/flight4a.exe", "Flight2"
'If using 9.5 and higher:
'WindowObject.LaunchAdd "C:/Program Files/HP/QuickTest Professional/samples/flight/app/flight4a.exe", "Flight2"
'Use the reference we gave in the previous statement (Flight2):
With WindowObject.Name("Flight2")
.WinEdit("attached text:=Agent Name:").Set "mercury"
.WinEdit("attached text:=Password:").Set "mercury"
.WInButton("text:=OK").Click
End With
'============================================
'AddNew
'============================================
MsgBox "Demonstrating AddNew: It will automatically add the newly open window and execute a few statements."
'Add the last open window to the collection as "FlightReservation1"
WindowObject.AddNew "FlightReservation1", 20
With WindowObject.Name("FlightReservation1")
.Highlight
.WinObject("attached text:=Date of Flight:", "index:=0").Type "09/09/12"
.WinComboBox("attached text:=Fly From:", "index:=0").Select "Denver"
.WinComboBox("attached text:=Fly To:", "index:=0").Select "Frankfurt"
.WinButton("text:=FLIGHT").Click
End With
Dialog("text:=Flights Table").WinButton("text:=OK").Click
With WindowObject.Name("FlightReservation1")
.WinEdit("attached text:=Name:", "index:=0").Type "Relevant Codes 1"
.WinButton("text:=&Insert Order").Click
.WinObject("nativeclass:=AfxWnd40").WaitProperty "regexpwndtitle", "Insert Done...", 30000
End with
'Release object
WindowObject.Destroy
- QTP测试多个Windows应用程序的解决方案
- QTP测试多个浏览器窗口的解决方案
- QTP测试Windows计算器
- QTP测试时,应用程序或者网页的最大化最小化控制
- QTP测试时,应用程序或者网页的最大化最小化控制
- 【软件测试自动化-QTP系列讲座 40】== 创建多个QTP实例 ==
- Windows 8的应用程序商店的前10个测试失败
- 利用QTP在WEB应用程序上进行简单的猴子测试
- (翻译)Windows应用程序的GUI测试指南
- (翻译)Windows应用程序的GUI测试指南
- Windows应用程序的GUI测试指南
- Windows应用程序的GUI测试指南
- QTP软件测试 Windows计算器自动化脚本
- 解决QTP在某些windows应用程序中对edit控件的set失败问题
- 解决QTP在某些windows应用程序中对edit控件的set失败问题
- QTP测试PDF的方法
- 第一个windows应用程序
- 第一个windows应用程序
- Ubuntu下从零开始用Iptables L7彻底封QQ
- wsprintf用法
- erp实施学习
- 使用ImageMagick 的提示与技巧 二
- 解决spring hibernate,session延迟加载的配置文件
- QTP测试多个Windows应用程序的解决方案
- uc/os ii 学习笔记 2010-03-19 b
- 使用ImageMagick 的提示与技巧 三
- Android ethernet support
- 使用ImageMagick 的提示与技巧 四
- perl中二维哈希的使用
- Win32 关键点总结
- c#实现魔兽(warIII)中显血和改键功能 (附源码)(代码参考sohighthesky)
- 记录两个SQL生成汉字全拼及拼音简码的方法