lucky666 发表于 2008-8-4 17:52:55

QTP内置函数Print的使用

各位大虾帮帮我!今天看了Flight例子用Print打印Flights Table控件的航班信息。可是我怎么也做不对。帮帮我!:L

小孩 发表于 2008-8-4 23:41:59

printWindow("Flight Reservation").Dialog("Flights Table").WinList("From").GetROProperty ("all items")

lucky666 发表于 2008-8-5 09:08:03

以下是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:05

首先确保这句话是否正确
Window("Flight Reservation").Dialog("Flights Table").WinList("From").GetROProperty("all items")

lucky666 发表于 2008-8-5 09:22:40

我想问一下,Print放在脚本中的什么地方?

lucky666 发表于 2008-8-5 09:26:33

Pint语法是什么呢:L :L 帮帮我吧!
我做了好多遍都没实现!

zhou840401 发表于 2008-8-5 09:38:13

要对症下药啊,提示类型不匹配,查一下其它的代码有没有错误啊,不一定就是print 那一句出错。

zhou840401 发表于 2008-8-5 09:38:46

去掉, print语句,看其它的能不能正确的运行,会不会出错。

lucky666 发表于 2008-8-5 10:47:07

其它语句没问题。就是提示Print语句类型不匹配

小孩 发表于 2008-8-5 11:03:01

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:28

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:22

刚才我用msgbox做了一次通过了。但在用Print时就又不行了。我用的是QTP8.2版本的!
感谢各位为我出点子,想办法!:victory: :handshake

ppent 发表于 2008-8-5 15:47:34

是不是qtp9.2没有这个方法了?没看到

小孩 发表于 2008-8-5 17:30:01

Print 估计8.2没有这个函数 我几乎不玩8.2

没有蛀牙 发表于 2008-8-5 17:53:22

不知道你为什么不行
我9.2上可以的
会弹出一个QucikTest Print Log 的界面

hsjzfling 发表于 2008-8-5 18:03:31

看看帮助文档就好了,现成的全都有

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.

hblxp321 发表于 2010-2-24 14:41:25

放置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:33

大家关注的地方错了吧?QTP8.2里面貌似没有print这个函数的

YangMay 发表于 2010-3-8 11:23:34

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

MessageStringString 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:15

Print 是调试语句
页: [1] 2
查看完整版本: QTP内置函数Print的使用