51Testing软件测试论坛

标题: QTP内置函数Print的使用 [打印本页]

作者: lucky666    时间: 2008-8-4 17:52
标题: QTP内置函数Print的使用
各位大虾帮帮我!今天看了Flight例子用Print打印Flights Table控件的航班信息。可是我怎么也做不对。帮帮我!
作者: 小孩    时间: 2008-8-4 23:41
print  Window("Flight Reservation").Dialog("Flights Table").WinList("From").GetROProperty ("all items")
作者: lucky666    时间: 2008-8-5 09:08
以下是Print语句的代码,可是总是提示类型不匹配。
Window("Flight Reservation").WinButton("Button").Click
Window("Flight Reservation").WinObject("Date of Flight:").Type "111213"
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").Activate
Window("Flight Reservation").Dialog("Flights Table").Activate
Window("Flight Reservation").Dialog("Flights Table").WinList("From").Select "15789   DEN   12:48 PM   FRA   01:33 PM   AA     $106.00"
Window("Flight Reservation").Dialog("Flights Table").Activate
Print Window("Flight Reservation").Dialog("Flights Table").WinList("From").GetROProperty("all items")
作者: 423799223    时间: 2008-8-5 09:10
首先确保这句话是否正确
Window("Flight Reservation").Dialog("Flights Table").WinList("From").GetROProperty("all items")
作者: lucky666    时间: 2008-8-5 09:22
我想问一下,Print放在脚本中的什么地方?
作者: lucky666    时间: 2008-8-5 09:26
Pint语法是什么呢 帮帮我吧!
我做了好多遍都没实现!
作者: zhou840401    时间: 2008-8-5 09:38
要对症下药啊,提示类型不匹配,查一下其它的代码有没有错误啊,不一定就是print 那一句出错。
作者: zhou840401    时间: 2008-8-5 09:38
去掉, print语句,看其它的能不能正确的运行,会不会出错。
作者: lucky666    时间: 2008-8-5 10:47
其它语句没问题。就是提示Print语句类型不匹配
作者: 小孩    时间: 2008-8-5 11:03
Window("Flight Reservation").WinObject("Date of Flight:").Type "111213"
Window("Flight Reservation").WinComboBox("Fly From:").Select "Denver"
Window("Flight Reservation").WinComboBox("Fly To:").Select "Frankfurt"
Window("Flight Reservation").WinButton("FLIGHT").Click
Print Window("Flight Reservation").Dialog("Flights Table").WinList("From").GetROProperty("all items")
作者: lingxin5013    时间: 2008-8-5 11:04
msgbox Window("Flight Reservation").Dialog("Flights Table").WinList("From").GetROProperty("all items")
使用msgbox看看怎么样 是否正确 如果正确使用下面在来一次看看
items=Window("Flight Reservation").Dialog("Flights Table").WinList("From").GetROProperty("all items")
print items
作者: lucky666    时间: 2008-8-5 11:28
刚才我用msgbox做了一次通过了。但在用Print时就又不行了。我用的是QTP8.2版本的!
感谢各位为我出点子,想办法!
作者: ppent    时间: 2008-8-5 15:47
是不是qtp9.2没有这个方法了?没看到
作者: 小孩    时间: 2008-8-5 17:30
Print 估计8.2没有这个函数 我几乎不玩8.2
作者: 没有蛀牙    时间: 2008-8-5 17:53
不知道你为什么不行
我9.2上可以的
会弹出一个QucikTest Print Log 的界面
作者: hsjzfling    时间: 2008-8-5 18:03
看看帮助文档就好了,现成的全都有

Use the Print Utility statement in your test to display information in the QuickTest Print Log window while still continuing the run session. For example, the following example iterates all the items in the Flight Table dialog (in the sample Flight application) and uses the Print Utility statement to print the content of each item to the QuickTest Print Log window.

Set FlightsList = Window("Flight Reservation").Dialog("Flights Table").WinList("From")
For i = 1 to FlightsList.GetItemsCount
              Print FlightsList.GetItem(i - 1)
Next

The QuickTest Print Log window remains open throughout the run session, until you close it.
[attach]44527[/attach]
作者: hblxp321    时间: 2010-2-24 14:41
标题: 放置print代码的位置是关键,要保证被测试窗口未关闭
Dialog("Login").WinEdit("Agent Name:").Set "mercury"
Dialog("Login").WinEdit("Password:").SetSecure "4b84c75060c89e9f0312c66f4e3fa6c7fcceaf3f"
Dialog("Login").WinButton("OK").Click
Window("Flight Reservation").ActiveX("MaskEdBox").Type "121212"
Window("Flight Reservation").WinComboBox("Fly From:").Select "Frankfurt"
Window("Flight Reservation").WinComboBox("Fly To:").Select "London"
Window("Flight Reservation").WinButton("FLIGHT").Click
Window("Flight Reservation").Dialog("Flights Table").WinList("From").Select "13508   FRA   10:24 AM   LON   11:09 AM   SR     $160.20"

Set FlightsList =  window("Flight Reservation").Dialog("Flights Table").WinList("From")
For i = 1 to FlightsList.GetItemsCount
         'Print FlightsList.GetItem(i-1)
Next

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

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

print的代码要放置在你航班选择窗口未关闭的位置,明白了吗
作者: 风雪夜归人    时间: 2010-2-24 15:19
大家关注的地方错了吧?QTP8.2里面貌似没有print这个函数的
作者: YangMay    时间: 2010-3-8 11:23
标题: QTP现成帮助文档.Share
QuickTest Professional Object Model Reference

Print Statement
Description
Displays information in the QuickTest Print Log window during the run session. The QuickTest Print Log window remains open while the run session continues, until you close it.

For more information, refer to the QuickTest Professional User's Guide.

Syntax
Print (Message)


Argument
Type
Description

Message  String  String expression displayed as the message in the QuickTest Print Log window.  


Example
The following example iterates all the items in the Flight Table dialog (in the sample Flight application) and uses the Print utility statment to print the content of each item to the QuickTest Print Log window.

Set FlightsList = Window("Flight Reservation").Dialog("Flights Table").WinList("From")

For i = 1 to FlightsList.GetItemsCount

              Print FlightsList.GetItem(i - 1)

Next
作者: liujinkui    时间: 2010-3-8 12:46
Print 是调试语句
作者: zhengpeipei    时间: 2010-3-8 13:42
路过
作者: shingo0109    时间: 2011-1-28 14:17
为啥我在QTP里直接输入语句Print "aaaa", 跑的时候会报错呢?




欢迎光临 51Testing软件测试论坛 (http://bbs.51testing.com/) Powered by Discuz! X3.2