VirtualBrowsers Object

Applies to TestComplete 15.69, last modified on November 13, 2024

Description

The VirtualBrowser object provides access to the mobile browser profiles defined in the project’s Virtual Browsers properties. Note that only the enabled profiles (those that are checked in the Virtual Browsers properties) can be accessed via the VirtualBrowsers object.

The VirtualBrowsers object lets you:

Requirements

  • A license for the TestComplete Web module

  • The Web Testing and Chrome Support plugins (they are part of the Web module)

  • Google Chrome 130

    If you have a TestComplete version earlier than 12.42, your version of the SmartBear Test Extension will be incompatible with newer versions of the Chrome web browser. To test web applications in Chrome 130, you will have to upgrade your TestComplete to some later version. We recommend using version 15.69.

    If you use a later version of Google Chrome, check whether a patch is available for it.

For details, see Requirements for Mobile Web Testing Using Emulator.

Members

Example

This line launches the iPhone 7 browser emulator and opens a URL:

JavaScript, JScript

VirtualBrowsers.Item("Apple iPhone 7").Run("http://m.smartbear.com");

Python

VirtualBrowsers.Item["Apple iPhone 7"].Run("http://m.smartbear.com");

VBScript

Call VirtualBrowsers.Item("Apple iPhone 7").Run("http://m.smartbear.com")

DelphiScript

VirtualBrowsers.Item['Apple iPhone 7'].Run('http://m.smartbear.com');

C++Script, C#Script

VirtualBrowsers["Item"]("Apple iPhone 7")["Run"]("http://m.smartbear.com");

This example outputs a list of all enabled mobile browser profiles to the test log:

JavaScript, JScript

function Test()
{
  var browser, i;

  Log.Message("Total number of enabled browser profiles: " + VirtualBrowsers.Count);
  for (i = 0; i < VirtualBrowsers.Count; i++)
  {
    browser = VirtualBrowsers.Item(i);
    Log.AppendFolder(browser.Name);
    Log.Message("User agent: " + browser.UserAgent);
    Log.Message("Browser screen size: " + browser.ScreenHeight + "x" + browser.ScreenWidth);
    Log.PopLogFolder();
  }
}

Python

def Test():
  Log.Message("Total number of enabled browser profiles: " + str(VirtualBrowsers.Count))
  for i in range (0, VirtualBrowsers.Count): 
    browser = VirtualBrowsers.Item[i]
    Log.AppendFolder(browser.Name)
    Log.Message("User agent: " + browser.UserAgent)
    Log.Message("Browser screen size: " + str(browser.ScreenHeight) + "x" + str(browser.ScreenWidth))
    Log.PopLogFolder()

VBScript

Sub Test
  Dim browser, i

  Call Log.Message("Total number of enabled browser profiles: " & VirtualBrowsers.Count)
  For i = 0 To VirtualBrowsers.Count - 1
    Set browser = VirtualBrowsers.Item(i)
    Call Log.AppendFolder(browser.Name)
    Call Log.Message("User agent: " & browser.UserAgent)
    Call Log.Message("Browser screen size: " & browser.ScreenHeight & "x" & browser.ScreenWidth)
    Call Log.PopLogFolder
  Next
End Sub

DelphiScript

procedure Test;
var browser, i;
begin
  Log.Message('Total number of enabled browser profiles: ' + VarToStr(VirtualBrowsers.Count));

  for i := 0 to VirtualBrowsers.Count - 1 do 
  begin
    browser := VirtualBrowsers.Item[i];
    Log.AppendFolder(browser.Name);
    Log.Message('User agent: ' + browser.UserAgent);
    Log.Message('Browser screen size: ' + VarToStr(browser.ScreenHeight) + 'x' + VarToStr(browser.ScreenWidth));
    Log.PopLogFolder;
  end;
end;

C++Script, C#Script

function Test()
{
  var browser, i;

  Log["Message"]("Total number of enabled browser profiles: " + VirtualBrowsers["Count"]);
  for (i = 0; i < VirtualBrowsers["Count"]; i++)
  {
    browser = VirtualBrowsers["Item"](i);
    Log["AppendFolder"](browser["Name"]);
    Log["Message"]("User agent: " + browser["UserAgent"]);
    Log["Message"]("Browser screen size: " + browser["ScreenHeight"] + "x" + browser["ScreenWidth"]);
    Log["PopLogFolder"]();
  }
}

See Also

Testing Mobile Web Applications Using Emulator
VirtualBrowserInfo Object

Highlight search results