QTP: Regular expressions and Descriptive Programming

I am using some of the code I listed earlier in my blog to open and get the hwnd of some browser/page objects. However, one of the other automation engineers found an issue with my code. Apparently, the code had trouble opening a url like http://groups.google.com/grphp?. So, I began to work on it. QTP was returning the ever-useful “General Error“ error, so I had to sleuth this out for myself. I am using this construct in my code to get at the handle:

If Browser(“hwnd:=“ & strBrowser).Page(“url:=“ & oIE.Document.url).Exist(0) then

     strPage = Browser(“hwnd:=“ & strBrowser).Page(“url:=“ & oIE.Document.url).GetROProperty(“hwnd“)

End If

Now, the co-worker was getting the aforementioned General Error (i.e., I am broke and not smart enough to tell you why) on the line inside the If. So, descriptive programming worked fine to get in there. However, when it got to the line inside, it didn't. I added some code to place a “\“ in front of the ? the co-worker passed (to indicate that the ? should be treated literally), and it works fine. I modified the code I now use to look for this issue and correct it without direction.

My only issue is: why the heck did it work fine on the Exist line, but not the GetROProperty line?

Lesson learned: be mindful of regular expressions in your descriptive programming.

 

Join me at:

SC Code Camp 2.0

 

«May»
SunMonTueWedThuFriSat
30123456
78910111213
14151617181920
21222324252627
28293031123
45678910