Browsers Object

Applies to TestComplete 14.30, last modified on November 21, 2019

Description

The Browsers object is a collection of all supported browsers that are available on the current computer. The items of this collection describe each of the available browsers. At runtime, you can also use this object to check which browser is currently used in the web test.

The Browsers object is available only if the Web Testing plugin is installed.

Members

Example

The following routine uses the properties and methods of Browsers and BrowserInfo objects to list all installed and supported browsers.

JavaScript, JScript

function ListBrowsers()
{
  var browser;
  
  for (var i=0; i < Browsers.Count; i++)
  {
    browser = Browsers.Item(i);
    Log.Message("Browser " + aqConvert.IntToStr(i) + " : " + browser.Description);
  }
}

Python

def ListBrowsers():
  for i in range (0, Browsers.Count-1):
    browser = Browsers.Item(i); 
    Log.Message("Browser " + aqConvert.IntToStr(i) + " : " + browser.Description);

VBScript

Sub ListBrowsers
  Dim browser
 
  For i = 0 To Browsers.Count-1
    Set browser = Browsers.Item(i)
    Log.Message("Browser " + aqConvert.IntToStr(i) + " : " + browser.Description)
  Next
End Sub

DelphiScript

procedure ListBrowsers;
var
  browser, i : OleVariant;
begin
  for i:=0 to Browsers.Count-1 do 
  begin
    browser := Browsers.Item(i);
    Log.Message('Browser ' + aqConvert.IntToStr(i) + ' : ' + browser.Description);
  end;
end;

C++Script, C#Script

function ListBrowsers()
{
  var browser;
  
  for (var i=0; i < Browsers["Count"]; i++)
  {
    browser = Browsers["Item"](i);
    Log["Message"]("Browser " + aqConvert["IntToStr"](i) + " : " + browser["Description"]);
  }
}

Note: If your tests uninstall or install browsers during the run, call the Browsers.Refresh method before working with the Browsers collection after installing or uninstalling a browser.

See Also

Testing Web Applications
BrowserInfo Object

Highlight search results