Count of open IE browsers — QTP

Posted On June 12, 2010

Filed under QTP

Comments Dropped leave a response

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

Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.