Search code examples
browserqtpchild-objects

Double number of items returned by Desktop.ChildObjects


I am trying to get all the open Browser objects using QTP11. The code I use is the following:

Set descBrowser = Description.Create
descBrowser("micClass").Value = "Browser"

Set objChildren = Desktop.ChildObjects( descBrowser )

During testing, i have two IE Browser windows open, but the collection returned by the code shows four found items. I checked the running processes also, which show the correct number of 2 processes running.

I have also checked with 3 Browsers open, in which case it shows 6 objects matching the descrption.

Can anybody explain why this could be happening?


Solution

  • I see the same behaviour (only for IE not Firefox).

    A workaround for this can be to filter out duplicates. For IE if you compare the objChildren(i).GetROProperty("hwnd") you can filter out those with the same value but this will not work if you also use Firefox since in Firefox if you have multiple tabs they all have the same hwnd.

    If you have to take FF into consideration you can filter out duplicates using the CreationTime property (instead of the hwnd).