qtp中循环部分代码未执行就跳过了怎么回事
qtp中循环部分代码未执行就跳过了怎么回事,代码中执行到for之后直接跳到最后一行了下面是代码(测试程序是自带的订票系统,代码主要功能是删除已经订票的信息)
Dim i
Dim j
'登录部分
Dialog("Login").WinEdit("Agent Name:").Set "zhangq"
Dialog("Login").WinEdit("Agent Name:").TypemicTab
Dialog("Login").WinEdit("Password:").SetSecure "5214c29da9670b6102ec4ae0509cb28227ffc292"
Dialog("Login").WinEdit("Password:").TypemicReturn
'查询订票信息
Window("Flight Reservation").WinButton("Button").Click
Window("Flight Reservation").Dialog("Open Order").WinCheckBox("Customer Name").Set "ON"
Window("Flight Reservation").Dialog("Open Order").WinEdit("Edit").Set "zhangq"
Window("Flight Reservation").Dialog("Open Order").WinButton("OK").Click
'获取列表中数据的数目
i = Window("Flight Reservation").Dialog("Open Order").Dialog("Search Results").GetROProperty("items count")
'此处想使用msgbox将i的值弹出框显示,如何编写????
'使用循环将已订票信息删除
For j = 0 to (i-1)
Window("Flight Reservation").Dialog("Open Order").Dialog("Search Results").WinList("Flight No.").Select j
Window("Flight Reservation").Dialog("Open Order").Dialog("Search Results").WinButton("OK").Click
Window("Flight Reservation").WinButton("Delete Order").Click
Window("Flight Reservation").Dialog("Flight Reservations").WinButton("是(Y)").Click
'判断是否还存在删除的数据,不存在则退出循环
If j = i -1Then
'Window("Flight Reservation").WinMenu("Menu").Select("File;exit")
Exit for
End If
Window("Flight Reservation").WinButton("Button").Click
Window("Flight Reservation").Dialog("Open Order").WinCheckBox("Customer Name").Set "ON"
Window("Flight Reservation").Dialog("Open Order").WinEdit("Edit").Set "zhangq"
Window("Flight Reservation").Dialog("Open Order").WinButton("OK").Click
Next
'退出系统
Window("Flight Reservation").WinMenu("Menu").Select "File;Exit" 直接msg i不就可以了?这代码写的。。。。哎。。 1、可能是i 的值未取到或取到的值为0,导致For j = 0 to (i-1) 中的i-1为负数,所以循环体未执行
2、打印i值:print i 或 msgbox i 打印I 或者直接在Debug中单步观察
页:
[1]