Close All Browser Except Latest One QTP VB

Posted by rajivkumarnandvani on May 13, 2009

Hi All,

Some time we required that Only Latest open Browser Window( Only for IE) will remain Open and rest of all shall be closed during QTP scripting. Here is the Function which will close the all open Browser except Latest Open browser (Work only for Internet Explorer using QTP)

Public function fn_CloseAllBrowserExceptLatest

rem create Browser description object

Set brwsr=Description.Create

rem get  all open Browser collection in Object
Set obj=Desktop.ChildObjects(brwsr)
browserCount= obj.count
Set obj=nothing

rem check if open browser count greater then one or Not
If  browserCount >1Then

rem If greater than one then close all open browser except latest using Creation Time property in QTP
For a =0 to browserCount -2

End If

End function


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: