Monday, 23 May 2011

Close All Browsers Except OLD One QTP VB

Hi All,
Some times we required that Only OLD open Browser Window( Only for IE) will remain Open and rest of all should be closed during QTP scripting. Here is the Function which will close all the open Browsers except OLD Open browser (Work only for Internet Explorer using QTP)

Public function fn_CloseAllBrowsersExceptOLD
      rem create Browser description object

         Set brwsr=Description.Create


         Set obj=Desktop.ChildObjects(brwsr)

          browserCount= obj.count

         Set obj=nothing

         If  browserCount >1  Then



            Set obj=Desktop.ChildObjects(brwsr)

            browserCount= obj.count

            Set obj=nothing

         loop  until  browserCount =1

        End If
End Function

call  fn_CloseAllBrowsersExceptOLD( )


Anonymous said...

very nice...........

Anonymous said...

hey rajiv.. QTP gives an error(invalid character) on
Error - Invalid character
Line (6): "brwsr(“micclass”).value= ”Browser”".
PLZ reply as soon as possible

RajivKumarNandvani said...

It seems you just copy paste the code in QTP.Just replace the double quote by manual typing the Double quote.because it is not the same which you copied from blog. you can also check the difference by manual typing the double Quote . Same case is applicable to single quote..
best of luck

Post a Comment

Which one is right ?