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
brwsr(“micclass”).value=”Browser”
Set obj=Desktop.ChildObjects(brwsr)
browserCount= obj.count
Set obj=nothing
If browserCount >1 Then
do
Browser(“CreationTime:=1″).Close
Set obj=Desktop.ChildObjects(brwsr)
browserCount= obj.count
Set obj=nothing
loop until browserCount =1
End If
End Function
call fn_CloseAllBrowsersExceptOLD( )
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
brwsr(“micclass”).value=”Browser”
Set obj=Desktop.ChildObjects(brwsr)
browserCount= obj.count
Set obj=nothing
If browserCount >1 Then
do
Browser(“CreationTime:=1″).Close
Set obj=Desktop.ChildObjects(brwsr)
browserCount= obj.count
Set obj=nothing
loop until browserCount =1
End If
End Function
call fn_CloseAllBrowsersExceptOLD( )
3 comments:
very nice...........
hey rajiv.. QTP gives an error(invalid character) on
brwsr(“micclass”).value=”Browser”
line.
Error - Invalid character
Line (6): "brwsr(“micclass”).value= ”Browser”".
PLZ reply as soon as possible
hi,
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