June 11, 2008
object.exist() in QTP needs company
It took me some time last week to figure out that the .exist() method does not work on a stand alone base. It passes a return value, and you need to do something with that value. For normal usage of .exist() this is obvious:
If QTPobject.exist Then msgbox "The object is present!"
But as a WinRunner user (did I mention that before?) I use the appearance of objects as an intrinsic synchronization method like:
btn_click("Open New Window");
win_exists("New Window", wait_normal); # synchronize 'wait_normal' seconds
set_window("New Window", 1);
...
Since I did a lot with webtesting, I didn't like to use the set_window() function before the frame was actually present, because it could cause a IE crash. That is why I used the win_exists() function.
But now in QTP. When you use .exist() with QTP objects in this way, it won't work:
QTPobject.exist
or
call QTPobject.exist
results in an 'Method is not valid for this object' error.
The only way to let it work, is passing the outcome to a dummy variable:
dummy = QTPobject.exist
This sometimes exotic behavior of QTP can be frustrating.
Subscribe to:
Post Comments (Atom)
2 comments:
exist is a property, not a method,
so it cannot be used alone.
Nice to view your blog,
Carson Guo
Thanks for sorting that out Carson, I certainly overlooked the possibility of exist being a property. That will explain the "method does not exist" error message (:
Post a Comment