Count of open IE browsers — QTP
Here is a small piece of code, which gives the number of existing internet explorers.
bcount = Get_ApplicationCount(“iexplore.exe”)
If bcount >0 Then
Print “There are” & chr(32) & bcount & “open Internet Explorer browsers”
set objBrowser = Description.Create()
objBrowser(“micclass”).value =”Browser”
objBrowser(“CreationTime”).value=bcount-1
Print Browser(objBrowser).GetROProperty(“Title”)
Else
Print “There are no open Internet Explorer browsers”
End If
Public Function Get_ApplicationCount( byval sApplicationExe)
Dim strComputer
Dim objWMIService
Dim colProcesses
Dim objProcess
strComputer=”.”
Set objWMIService = GetObject(“winmgmts:\\” & strComputer & “\root\cimv2″)
Set colProcesses = objWMIService.ExecQuery (“Select * from Win32_Process Where Name = ” & “‘” & sApplicationExe & “‘” & ” “)
Get_ApplicationCount = colProcesses.count
Set objWMIService = Nothing
Set colProcesses=Nothing
End Function
June 12, 2010