The following function “BrowserCount()” will return the total number of Browser Window instances opened.

Imports

SilkTest.Ntf.XBrowser

Public

ModuleMain

   Dim _desktop AsDesktop = Agent.Desktop

   Public Function BrowserCount() As Integer
     Dim myWindows As New List(Of TestObject)
     Dim nBrowserCount As Integer

     myWindows = _desktop.FindAll(
"/BrowserApplication")
     nBrowserCount = myWindows.Count()
    Return nBrowserCount
   End Function

   Public SubMain()

   Console.WriteLine(

"")
   Console.WriteLine(
"The total no of browsers opened is: " & CStr(BrowserCount()))
   Console.WriteLine(
"")

   End Sub

End

Module

The only caveat is that you need to add an “Application Configuration” for the browser which you wish to execute the function against.