Geeks With Blogs

News QTP and Stuff
Theo Moore Questions... Morphology? Longevity? Incept dates?


I strongly dislike waiting. This applies at the drugstore, the DMV, or any other place. I patiently accept that this happens, however, since life is just like that. I do try to avoid it whenever reasonably possible, especially at work.


Which explains why I try to never use a Wait() statement in QTP. Wait seems like a cop-out; rather than attempt to find that one property that indicates the state of my application, I’ll put pick a time and hope for the best. My linear-thinking, anal-retentive mind just can’t do it unless I have tried every other means imaginable (and unimaginable). It’s just how I am wired.


So, how does this relate to my title? Basically, I am often looking at Page/Browser object properties to determine my application state. However, I’ve noticed lately that the GetROProperty Function simply doesn’t work reliably. Here’s and example of what I mean:


With Browser("RE").Page("GEOMAP")

If Instr(UCase(.GetROProperty("url")), "GEOMAP") > 0 Then

.WebArea("alt:=" & DataTable.Value("A", dtLocalSheet)).Click



Loop Until Browser("hwnd:=" & Environment("BrowserHandle")).Page("url:=" & Environment("RE_Web") & "\home-listings/default.asp?state=NC").Exist(1)

If Instr(Browser("hwnd:=" & Environment("BrowserHandle")).Page("url:=" & Environment("RE_Web") & "\home-listings/default.asp?state=NC").GetROProperty(“title”), “Test”) > 0 Then

<do something>

End If


End If

End With


In this snippet, we are trying to determine if we are on the correct page using the .GetROProperty(url”). Sometimes this works, and sometimes it doesn’t. We later use a loop to determine if we are on the correct page post clicking on the correct WebArea. If we are, we use a custom solution to deal with popup dialogs and clear them all. We then attempt to access the title of the page to determine if we should do something else. Sometimes, even the descriptive programming in these cases won’t work correctly 100% of the time.


So what do you do? I am glad you asked! Normally, I rely on the Page.Object to determine my current state. This is a reference of the XMLDocument under the page, and is therefore usually more “up to the minute” than the functions that QTP provides natively. Using the above code, I could get at anything I could under the GetROProperty, and some I can’t. Easiest thing to do is use object spy in QTP to determine what’s available (much as you might for GetROProperty), but I also consult an XMLDocument reference to see if there is anything else there I can use. An example of how I would use the XMLDocument might be:

Browser("hwnd:=" & Environment("BrowserHandle")).Page("url:=" & Environment("RE_Web") & "\home-listings/default.asp?state=NC").Object.title


This method seems to work much more reliably that GetROProperty most of the time, and after all, who likes to wait?

Posted on Tuesday, April 4, 2006 4:58 AM | Back to top

Comments on this post: QTP: GetROProperty vs. Page.Object

# re: QTP: GetROProperty vs. Page.Object
Requesting Gravatar...
Funny, every time I use the Page.Object properties I feel guilty. Guilty because I convinced my company to spend a ton of money on this software, and in the end I'm not really using it. When I go for Page.Object, I'm admitting defeat, I'm saying "Mercury's software isn't working, so I'm just going to use the DOM and get it over with".

I's so much more reliable and predictable that it's frightening. Why put a wrapper around something when the wrapper doesn't work? That's why I always hesitate before using it.

Then GetROProperty stops working after a code change, and I get so mad that I end up going that way anyway, and I wonder why I didn't just implement my own DOM-wrapping automated test harness.


Good stuff, man.
Left by Marcus on Apr 04, 2006 5:43 AM

# re: QTP: GetROProperty vs. Page.Object
Requesting Gravatar...
Thanks, boss. I know what you mean, too. I always try to use the QTP native functionality much for the same reason you do. I only abandon it when it doesn't work. I, too, have almost re-written several pieces of QTP myself. Heck, I'm already working on a cursor-based replacement for the DataTable because I find it so frustrating to use. I am very careful not to voice this to the management who purchased the software, however... ;-)

Left by Theo Moore on Apr 04, 2006 5:50 AM

# re: QTP: GetROProperty vs. Page.Object

# re: QTP: GetROProperty vs. Page.Object
Requesting Gravatar...
I have experienced this problem many times myself. I don't feel bad about using the run time properties though. Every tool has its quirks and if we wrote our own wrapper to the OM, I am sure that would too. One thing I have also found is that somtimes on certain objects WinButton for example, run time properties are not available though the .Object approach. That's when things really get messy.
Left by cody on Aug 09, 2007 2:02 PM

# re: QTP: GetROProperty vs. Page.Object
Requesting Gravatar...
QTP wait
Left by Wait on Jan 16, 2008 10:55 PM

Comments have been closed on this topic.
Copyright © Theo Moore | Powered by: