I am working on a DLL that I can call that will open an instance of Internet Explorer, and then return its Browser handle and Page handle. I am trying to write procedures that will handle functionality totally independent of the text in the title, the text on the page, or whatever else QTP uses to reference these objects. Basically, I am frustrated having to fix regular expressions or whatever to make sure my references work. It seems like a no-brainer to me that I should be able to open a browser, and get the handles to the browser and the page (only one assuming IE 6) underneath it. Yes, I can use the GetROProperty to get that value, but it assumes that the property I use to get the value hasn't changed or isn't determined dynamically. If it has, this doesn't work reliably.
Just a quick design criticisim of QTP: Why in the world there isn't a built-in function called “OpenBrowser” I'll never know. That function should return the handles to you. However, there isn't. So, here I am working to write it myself.
I have a rough set of code that does exactly what I want, but I need to refactor it (read as: make into something less ugly) before I use it. Whilst I was working on this, I found something interesting:
If you use a late-bound instance of internet explorer (CreateObject(”InternetExplorer.Application”)) vice an early-bound, QTP will *not* have any clue how to interact with it. If you try to object spy the fields on it, it will tell you that you are looking at WinApp and a WinObject (Browser and Page) and referring to the objects via handle will fail. Basically, QTP will not be able to determine what they are. Seems to me it would know by asking what the class is by using the handle it can get. I mean, that's what I do in my code to get the the correct handle in the first place. If you use the early-bound method, this works fine. Interesting, but the pity that the code would have to written in VB and compiled rather than use VBScript. 'Course, I am using callback API functions in the code, so I am stuck doing VB anyway.
Just something I hope I can relate to save someone else a few hours of pain.