Specifying Additional Parameters for Mobile Browser Emulator

Applies to TestComplete 14.0, last modified on January 23, 2019

This topic explains how you can specify command-line parameters for the mobile browser emulator in automated tests to customize the emulator behavior.

About the Emulator’s Command-Line Parameters

TestComplete lets you test mobile web applications using the mobile emulation mode of Google Chrome. Chrome has many command-line parameters for various purposes. You can find them, for example, here:

http://peter.sh/experiments/chromium-command-line-switches/

When you start the mobile browser emulator from TestComplete (for example, by using the Run Virtual Browser keyword test operation), it launches Chrome with the following default parameters:

  • --user-agent – Overrides Chrome’s default user agent string with the specified one.

  • --window-size, --page-size – Sets Chrome's window size to emulate the mobile browser’s screen size.

  • --disable-hang-monitor – Disables Chrome’s hang monitor so that it does not report the SmartBear Test extension as unresponsive during automated testing.

  • --disable-translate – Disables automatic translation prompt so that it does not interfere with the tests.

You can also specify additional parameters for the mobile browser emulator in your tests. Some useful parameters for automated testing include –

  • --no-default-browser-check – Disables the default browser check on Chrome startup.

  • --mute-audio – Disables sound in Chrome.

Setting the Emulator’s Command-Line Parameters in Tests

You can use the VirtualBrowsers.Item(browser_name).RunOptions property to specify the emulator’s command-line parameters to be used with a specific browser profile. You can list multiple parameters separated by spaces.

Keyword Tests

In keyword tests, use the Call Object Method operation to set the emulator’s RunOptions property. Specify the following operation parameters:

Parameter Value
Object (or Item) VirtualBrowsers.Item(browser_name)

For example, VirtualBrowsers.Item("Apple iPhone 5").

Method or property (or Operation) RunOptions [Set]
Value A string with command-line arguments
Specifying command-line arguments for mobile browser emulator in keyword tests

Scripts

In scripts, you can set the emulator’s RunOptions property for a specific browser profile as follows:

JavaScript, JScript

function Test1()
{
  // Specify command-line parameters for the emulator
  var emulator = VirtualBrowsers.Item("Apple iPhone 5");
  emulator.RunOptions = "--no-default-browser-check --mute-audio";

  // Launch the emulator and open the tested web site
  emulator.Run("http://m.smartbear.com");

  // Perform testing
  // ...
}

Python

def Test1():
  # Specify command-line parameters for the emulator
  emulator = VirtualBrowsers.Item("Apple iPhone 5");
  emulator.RunOptions = "--no-default-browser-check --mute-audio";

  # Launch the emulator and open the tested web site
  emulator.Run("http://m.smartbear.com");

  # Perform testing
  # ...

VBScript

Sub Test1
  Dim emulator

  ' Specify command-line parameters for the emulator
  Set emulator = VirtualBrowsers.Item("Apple iPhone 5")
  emulator.RunOptions = "--no-default-browser-check --mute-audio"

  ' Launch the emulator and open the tested web site
  Call emulator.Run("http://m.smartbear.com")

  ' Perform testing
  ' ...
End Sub

DelphiScript

procedure Test1;
var emulator;
begin
  // Specify command-line parameters for the emulator
  emulator := VirtualBrowsers.Item['Apple iPhone 5'];
  emulator.RunOptions := '--no-default-browser-check --mute-audio';

  // Launch the emulator and open the tested web site
  emulator.Run('http://m.smartbear.com');

  // Perform testing
  // ...
end;

C++Script, C#Script

function Test1()
{
  // Specify command-line parameters for the emulator
  var emulator = VirtualBrowsers["Item"]("Apple iPhone 5");
  emulator["RunOptions"] = "--no-default-browser-check --mute-audio";

  // Launch the emulator and open the tested web site
  emulator["Run"]("http://m.smartbear.com");

  // Perform testing
  // ...
}

If you have a cross-browser test, you need to set RunOptions inside the browser loop, like this:

JavaScript, JScript

function Test2()
{
  var emulator, i;

  for (i = 0; i < VirtualBrowsers.Count; i++)
  {
    // Specify command-line parameters for the emulator
    emulator = VirtualBrowsers.Item(i);
    emulator.RunOptions = "--no-default-browser-check --mute-audio";

    // Launch the emulator and open the tested web site
    emulator.Run("http://m.smartbear.com");

    // Perform testing
    // ...
    Aliases.browser.Close();
  }
}

Python

def Test2():
  for i in range (0, VirtualBrowsers.Count):
    # Specify command-line parameters for the emulator
    emulator = VirtualBrowsers.Item(i);
    emulator.RunOptions = "--no-default-browser-check --mute-audio";

    # Launch the emulator and open the tested web site
    emulator.Run("http://m.smartbear.com");

    # Perform testing
    # ...
    Aliases.browser.Close();

VBScript

Sub Test2
  Dim emulator, i

  For i = 0 To VirtualBrowsers.Count
    ' Specify command-line parameters for the emulator
    Set emulator = VirtualBrowsers.Item(i)
    emulator.RunOptions = "--no-default-browser-check --mute-audio"

    ' Launch the emulator and open the tested web site
    Call emulator.Run("http://m.smartbear.com")

    ' Perform testing
    ' ...
    Aliases.browser.Close
  Next
End Sub

DelphiScript

procedure Test2;
var emulator, i;
begin
  for i := 0 to VirtualBrowsers.Count - 1 do
  begin
    // Specify command-line parameters for the emulator
    emulator := VirtualBrowsers.Item[i];
    emulator.RunOptions := '--no-default-browser-check --mute-audio';

    // Launch the emulator and open the tested web site
    emulator.Run('http://m.smartbear.com');

    // Perform testing
    // ...
    Aliases.browser.Close;
  end;
end;

C++Script, C#Script

function Test2()
{
  var emulator, i;

  for (i = 0; i < VirtualBrowsers["Count"]; i++)
  {
    // Specify command-line parameters for the emulator
    emulator = VirtualBrowsers["Item"](i);
    emulator["RunOptions"] = "--no-default-browser-check --mute-audio";

    // Launch the emulator and open the tested web site
    emulator["Run"]("http://m.smartbear.com");

    // Perform testing
    // ...
    Aliases["browser"]["Close"]();
  }
}

Setting the Emulator’s Command-Line Parameters in the TestedApps Editor

If you added the mobile browser emulator to the list of tested applications (for example, to launch it at design time), you can specify the Command-line arguments in the TestedApps editor.

Specifying command-line arguments for mobile browser emulator in TestedApps

See Also

Testing Mobile Web Applications Using Emulator
Testing Mobile Web Applications Using Emulator - Overview
Launching Mobile Browser Emulator
Creating Mobile Browser Profiles
Adding Mobile Browser Emulator to TestedApps

Highlight search results