Automating QTP Test Automation Home Automation Articles Downloads QTP Gotchas Links Books Contact About Site Map
Browser Function - Close AllThis sub closes all currently open browsers. If you find an error, or have a suggestion for improvement, Email me and I'll fix it. Download it Here (right-click and then save target as). (NOTE - you can just cut & paste from below, but the formatting will have multiple spaces instead of tabs).
'=========================================================================
Sub zBro_CloseAll print "Bro_CloseAll" Dim oBrowserDesc, oBrowsers, iBrowserCount, iBrowserIndex, sBrowserName Set oBrowserDesc = Description.Create oBrowserDesc("micclass").Value = "Browser" Set oBrowsers = Desktop.ChildObjects(oBrowserDesc) iBrowserCount = oBrowsers.Count If iBrowserCount = 0 Then 'Print "BrowserCloseAll - There are no browsers open" Else 'Print "BrowserCloseAll - Open Browser Count: " & cStr(iBrowserCount) For iBrowserIndex = 0 To iBrowserCount - 1 'sBrowserName = oBrowsers(iBrowserIndex).getroproperty("name") 'Print "BrowserCloseAll - Closing: " & sBrowserName oBrowsers(iBrowserIndex).Close Next End If Set oBrowsers = Nothing Set oBrowserDesc = Nothing End Sub '========================================================================= |