Search This Blog

Friday, September 9, 2011

QTP & QC ->Code for to close all IE browsers except HP Quality Center

'**********************************************************************************************************
'Function Name:  sub_CloseOpenedBrowsers
'Description :        Used to close all IE browsers except HP Quality Center
'Parameters:        None
'Return  value       None
'Registerd To      NA
'Example:              fun_CloseOpenedBrowsers()
'**********************************************************************************************************
Sub sub_CloseOpenedBrowsers()
 Dim objDesktopChild, objDesktopChildCollection, intCounter, intHWND
 'Get collection of desktop objects
 Set objDesktopChild = Description.Create
 objDesktopChild("micclass").Value = "Browser"
 Set objDesktopChildCollection = Desktop.ChildObjects(objDesktopChild)
 'Identify the browsers and close all the browsers except HP QC
 For intCounter = 0 to objDesktopChildCollection.Count - 1
  If Instr( 1 , lcase(objDesktopChildCollection(intCounter).GetROProperty("title")) , "hp quality center" ) = 0 And Instr(1 , lcase(objDesktopChildCollection(intCounter).object.document.url) , "atc.jcpenny.com" ) = 0  Then
   intHWND = objDesktopChildCollection(intCounter).Object.HWND
   Systemutil.CloseProcessByHwnd(intHWND)
  End If
 Next

End Sub

No comments:

Post a Comment