Need solution for a known issue of UFT12 - ChildObjects
My requirement is to close all other browsers except the parent (with creationTime:=0). For this I wrote a code like-
Set ObjBrowsers=Desktop.ChildObjects(objBrowsersDescMa in)
If iBowserCount>0 Then
For iCount=iBowserCount-1 to 1 Step -1
Browser("name:=" & sName).Close
This was working till UFT 11.52. When I installed UFT 12, it is not working.
From the UFT 12 install guide / readme file, I came to know that ChildObjects is not working, instead they suggest to use GetItem() or GetItemProperty() methods but this will not work in case of Desktop object.
So can anybody suggest a solution for that?
Thanks for the reply but it is till not working.
It is not working in the case where there is only one Browser exists. It is closing it also.
Using IE? Probably have to change that to creation time 2. Since recent versions of IE spawn two processes at startup.
See the tricky part in the article below by Anshoo Arora, creationtime has no use in case of single browser open.
QTP?s Browser CreationTime
Moreover childobjects method do not consider ordinal identifiers as descriptions, see my post here,
CreationTime Not Supported For Desktop.ChildObjects
Rather Do a GetROProperty("hwnd") for parent browser or browser which you do not want to close. Then you can close other browser except with this hwnd.
Last edited by anandtambey; 06-16-2014 at 10:34 PM.
Reason: Adding another reference post
QTP: Closing Multiple Browser Windows
You may use the methods provided here to close all browser except one.
Thanks Anand for the solution. I am no more blocked on this but have few observations
1. As Desktop.ChildObjects does not provide correct result, this is still an open question regarding how to get the total existing Browsers.
2. Overall execution is slow if there is only Browser opened.
Chinmay have you thought about killing all browser processes in your initialise step, that way you should always know how many browsers are open at any point in your test (unless you have encountered an error which spawns another browser process, is this what you are checking for?)
Yes Mark, this is as part of exceptional handling or recovery scenario where before I execute next set of scenarios, I need to make sure that my application is in base state.
In our application there are lots of pop-up pages where scripts are navigating it so I need to make sure there are only single Browser exists when a new scenario is started.
Chinmay my suggestion here is ODD but still workable... In your case maximum how many browsers can open, let take maximum 20 and derive the following script
brwCnt = 20
If browser("Creationtime:="&brwCnt).Exist then
brwCnt = brwCnt - 1
Loop Until brwCnt<1