BrowserIndex Property

Applies to TestComplete 15.63, last modified on April 23, 2024

Description

The BrowserIndex property specifies the browser index among other running browsers with the same name.

For example, if you have two different Firefox versions installed and both of them are currently running, the first launched Firefox process has BrowserIndex of 1 and the other one has BrowserIndex of 2.

Similarly, if 32-bit and 64-bit versions of Internet Explorer are running at the same time on 64-bit Windows, one browser instance has BrowserIndex of 1 and the other one has BrowserIndex of 2.

Declaration

TestObj.BrowserIndex

Read-Only Property Integer
TestObj A variable, parameter or expression that specifies a reference to one of the objects listed in the Applies To section

Applies To

The property is applied to the following object:

View Mode

To view this property in the Object Browser panel and in other panels and dialogs, activate the Advanced view mode.

Property Value

An integer number (1-based) that specifies the browser index among other running browsers of the same name.

Example

The following example launches 32-bit and 64-bit versions of Internet Explorer and logs their BrowserIndex values. Note that this example requires a 64-bit version of Windows.

JavaScript, JScript

function Test()
{
  // Sys.Browser here refers to the Internet Explorer instance that was just launched

  Browsers.Item("iexplore", "", Browsers.pX86).Run("http://smartbear.com")
  Log.Message(Sys.Browser().BrowserIndex);

  Browsers.Item("iexplore", "", Browsers.pX64).Run("http://blog.smartbear.com");
  Log.Message(Sys.Browser().BrowserIndex);
}

Python

def Test():
  # Sys.Browser here refers to the Internet Explorer instance that was just launched

  Browsers.Item["iexplore", "", Browsers.pX86].Run("http://smartbear.com")
  Log.Message(Sys.Browser().BrowserIndex)

  Browsers.Item["iexplore", "", Browsers.pX64].Run("http://blog.smartbear.com")
  Log.Message(Sys.Browser().BrowserIndex)

VBScript

Sub Test
  ' Sys.Browser here refers to the Internet Explorer instance that was just launched

  Browsers.Item("iexplore", "", Browsers.pX86).Run "http://smartbear.com"
  Log.Message Sys.Browser.BrowserIndex

  Browsers.Item("iexplore", "", Browsers.pX64).Run "http://blog.smartbear.com"
  Log.Message Sys.Browser.BrowserIndex
End Sub

DelphiScript

procedure Test;
begin
  // Sys.Browser here refers to the Internet Explorer instance that was just launched

  Browsers.Item('iexplore', '', Browsers.pX86).Run('http://smartbear.com');
  Log.Message(Sys.Browser.BrowserIndex);

  Browsers.Item('iexplore', '', Browsers.pX64).Run('http://blog.smartbear.com');
  Log.Message(Sys.Browser.BrowserIndex);
end;

C++Script, C#Script

function Test()
{
  // Sys.Browser here refers to the Internet Explorer instance that was just launched

  Browsers["Item"]("iexplore", "", Browsers["pX86"])["Run"]("http://smartbear.com")
  Log["Message"](Sys["Browser"]()["BrowserIndex"]);

  Browsers["Item"]("iexplore", "", Browsers["pX64"])["Run"]("http://blog.smartbear.com");
  Log["Message"](Sys["Browser"]()["BrowserIndex"]);
}

See Also

ObjectType Property
ProcessName Property
ProcessType Property
Classic Web Testing
Understanding Web Object Identification and Object Models

Highlight search results