ApplicationManager Object

Applies to TestComplete 15.45, last modified on December 01, 2022

The information below concerns the ApplicationManager object available in cloud-compatible mobile tests. For information on the similar object that was available in legacy mobile tests, see ApplicationManager Object (Legacy).

Description

The ApplicationManager object provides access to applications installed on a mobile device running in the BitBar cloud or on a local Appium server to which TestComplete is connected. You can use this object to start and stop the tested applications on the mobile devices and to get the application state.

To obtain the object in tests, use the Device.ApplicationManager property.

Members

Example

The code below shows how to get the ApplicationManager object and how to use it to start, reset, and then stop the tested application for which the testing session is opened on the mobile device:

Note: For the example to work correctly, your project must be connected to the BitBar cloud and the bitbar_app capability must specify a correct application ID in the BitBar file storage. If you use an iOS device, the bundleId capability must also be specified for the testing session. See Project Properties > Device Cloud > Mobile.

JavaScript

function Test()
{
  // Connect to a mobile device
  var capabilities = {
    "platformName": "ANDROID",
    "bitbar_target": "android",
    "bitbar_findDevice": "false",
    "bitbar_device": "Google Pixel 3a Android 10",
    "deviceName": "Google Pixel 3a Android 10",
    "automationName": "UiAutomator2",
    "bitbar_app": "1234"
};
  var server = "https://appium.bitbar.com/wd/hub/";
  Mobile.ConnectDevice(server, capabilities);

  var appManager = Mobile.Device().ApplicationManager;
  // Launch the tested application
  appManager.LaunchTestedApp();

  // Simulate user actions
  // …

  // Switch the tested application to the background mode
  appManager.BackgroundTestedApp();
  // …

  // Reset and restart the tested application
  appManager.ResetTestedApp();
  // …

  // Close the tested application and stop the testing session
  appManager.CloseTestedApp();

}

JScript

function Test()
{

  // Connect to a mobile device
  var capabilities = "{\"platformName\":\"ANDROID\",\"bitbar_target\":\"android\",\"bitbar_findDevice\":false,\"bitbar_device\":\"Google Pixel 3a Android 10\",\"deviceName\":\"Google Pixel 3a Android 10\",\"automationName\":\"UiAutomator2\",\"bitbar_app\":\"1234\"}";
  var server = "https://appium.bitbar.com/wd/hub/";
  Mobile.ConnectDevice(server, capabilities);

  var appManager = Mobile.Device().ApplicationManager;
  // Launch the tested application
  appManager.LaunchTestedApp();

  // Simulate user actions
  // …

  // Switch the tested application to the background mode
  appManager.BackgroundTestedApp();
  // …

  // Reset and restart the tested application
  appManager.ResetTestedApp();
  // …

  // Close the tested application and stop the testing session
  appManager.CloseTestedApp();

}

Python

def Test():

  # Connect to a mobile device
  capabilities = {
    "platformName": "ANDROID", 
    "bitbar_target": "android", 
    "bitbar_findDevice": "false", 
    "bitbar_device": "Google Pixel 3a Android 10", 
    "deviceName": "Google Pixel 3a Android 10", 
    "automationName": "UiAutomator2", 
    "bitbar_app": "1234"
}
  server = "https://appium.bitbar.com/wd/hub/"
  Mobile.ConnectDevice(server, capabilities)

  appManager = Mobile.Device().ApplicationManager
  
  # Launch the tested application
  appManager.LaunchTestedApp

  # Simulate user actions
  # ...

  # Switch the tested application to the background mode
  appManager.BackgroundTestedApp
  # ...

  # Reset and restart the tested appication
  appManager.ResetTestedApp
  # ...

  # Close the tested application and stop the testing session
  appManager.CloseTestedApp

VBScript

Sub Test()

  ' Connect to a mobile device
  capabilities = "{""platformName"":""ANDROID"",""bitbar_target"":""android"",""bitbar_findDevice"":false,""bitbar_device"":""Google Pixel 3a Android 10"",""deviceName"":""Google Pixel 3a Android 10"",""automationName"":""UiAutomator2"",""bitbar_app"":""1234""}"
  server = "https://appium.bitbar.com/wd/hub/"
  Call Mobile.ConnectDevice(server, capabilities)

  Set appManager = Mobile.Device().ApplicationManager
  ' Launch the tested application
  appManager.LaunchTestedApp

  ' Simulate user actions
  ' …

  ' Switch the tested application to the background mode
  appManager.BackgroundTestedApp
  ' …

  ' Reset and restart the tested application
  appManager.ResetTestedApp
  ' …

  ' Close the tested application and stop the testing session
  appManager.CloseTestedApp

End Sub

DelphiScript

procedure Test();
var capabilities, server, appManager;
begin

  // Connect to a mobile device
  capabilities := '{"platformName":"ANDROID","bitbar_target":"android","bitbar_findDevice":false,"bitbar_device":"Google Pixel 3a Android 10","deviceName":"Google Pixel 3a Android 10","automationName":"UiAutomator2","bitbar_app":"1234"}';
  server := 'https://appium.bitbar.com/wd/hub/';
  Mobile.ConnectDevice(server, capabilities);

  appManager := Mobile.Device().ApplicationManager;
  // Launch the tested application
  appManager.LaunchTestedApp();

  // Simulate user actions
  // …

  // Switch the tested application to the background mode
  appManager.BackgroundTestedApp();
  // …

  // Reset and restart the tested application
  appManager.ResetTestedApp();
  // …

  // Close the tested application and stop the testing session
  appManager.CloseTestedApp();

end;

C++Script, C#Script

function Test()
{

  // Connect to a mobile device
  var capabilities = "{\"platformName\":\"ANDROID\",\"bitbar_target\":\"android\",\"bitbar_findDevice\":false,\"bitbar_device\":\"Google Pixel 3a Android 10\",\"deviceName\":\"Google Pixel 3a Android 10\",\"automationName\":\"UiAutomator2\",\"bitbar_app\":\"1234\"}";
  var server = "https://appium.bitbar.com/wd/hub/";
  Mobile["ConnectDevice"](server, capabilities);

  var appManager = Mobile["Device"]()["ApplicationManager"];
  // Launch the tested application
  appManager["LaunchTestedApp"]();

  // Simulate user actions
  // …

  // Switch the tested application to the background mode
  appManager["BackgroundTestedApp"]();
  // …

  // Reset and restart the tested application
  appManager["ResetTestedApp"]();
  // …

  // Close the tested application and stop the testing session
  appManager["CloseTestedApp"]();

}

See Also

About Mobile Tests

Highlight search results