|
QTP的场景恢复机制比较奇怪,起码跟我预想的不一样,经过实验得出以下结论:(当Test run error中选Any error时)
A=1/0 '<---------------- 不触发场景恢复
Browser("asdf").close '<---------------- 不触发场景恢复
Browser("name:=asdf").close '<---------------- 触发场景恢复
Window("Notepad").WinMenu("Menu").Select "asdf" '<---------------- 触发场景恢复
注意第二项,OR里不存在title为asdf的Browser,我估计QTP把它当作语法错误处理了,同一。
但是用DP写又触发了,见三。总之很奇怪,大家记住这个机制就好。我的QTP是9.1
附个例子:- Function Recovery_Example(Object)
- 'Returns a handle to a run-time object's window
- win_handle=Object.GetROProperty("hwnd")
- 'Assigning an object reference to a variable
- Set pop_win=Window("hwnd:=" & win_handle)
- 'Printing that object's title
- Msgbox pop_win.GetROProperty("title")
- 'Clicking OK button on that object.
- pop_win.WinButton("text:=OK").Click
- End Function
复制代码 |
|