ProcessState Property

Applies to TestComplete 15.47, last modified on January 20, 2023

Description

Returns the state of the process running on the mobile device and specified by its name.

Declaration

ApplicationManagerObj.ProcessState(ProcessName)

Read-Only Property String
ApplicationManagerObj An expression, variable or parameter that specifies a reference to an ApplicationManager object
ProcessName [in]    Required    String    

Applies To

The property is applied to the following object:

Parameters

The property has the following parameter:

ProcessName

Specifies the name of the process whose state you want to get.

For iOS, it is the bundle ID of the application that started the process. For example, com.apps.orders.

For Android, it is the name of the package that corresponds to the process. For example, com.example.orders.

Property Value

A string describing the state of the specified process.

Remarks

If the specified application is not installed on the device, the property may return the The process is not running status, and not the The process is not installed status.

Example

The code below shows how to get the ApplicationManager object and how to use it to manage a process running on a mobile device:

Note: For the example to work correctly, your project must be connected to the BitBar cloud, the bitbar_app capability must specify the correct application ID in the BitBar file storage, and the processName variable must specify the proper name of the process existing on the connected mobile device. 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;
  var processName = "smartbear.example.orders";

  // Launch the tested application
  appManager.LaunchTestedApp();

  // Switch the tested application to the background mode
  appManager.BackgroundTestedApp();
  // Post the process state to the test log
  Log.Message(appManager.ProcessState(processName));

  // Restore the process of the tested application from the background
  appManager.ActivateProcess(processName);

  // Terminate the process of the tested application
  appManager.TerminateProcess(processName);

}

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;
  var processName = "smartbear.example.orders";

  // Launch the tested application
  appManager.LaunchTestedApp();

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

  // Post the process state to the test log
  Log.Message(appManager.ProcessState(processName));

  // Restore the process of the tested application from the background
  appManager.ActivateProcess(processName);

  // Terminate the process of the tested application
  appManager.TerminateProcess(processName);

}

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
  processName = "smartbear.example.orders"
  
  # Launch the tested application
  appManager.LaunchTestedApp()
  
  # Switch the tested application to the background mode
  appManager.BackgroundTestedApp()
  
  # Post the process state to the test log
  Log.Message(appManager.ProcessState[processName])
  
  # Restore the process of the tested application from the background
  appManager.ActivateProcess(processName)
  
  # Terminates the process of the tested application
  appManager.TerminateProcess(processName)

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
  processName = "smartbear.example.orders"

  ' Launch the tested application
  appManager.LaunchTestedApp

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

  ' Post the process state to the test log
  Log.Message(appManager.ProcessState(processName))

  ' Restore the process of the tested application from the background
  appManager.ActivateProcess(processName)

  ' Terminate the process of the tested application
  appManager.TerminateProcess(processName)

End Sub

DelphiScript

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
  processName = "smartbear.example.orders"

  # Launch the tested application
  appManager.LaunchTestedApp()

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

  # Post the process state to the test log
  Log.Message(appManager.ProcessState[processName])

  # Restore the process of the tested application from the background
  appManager.ActivateProcess(processName)

  # Terminate the process of the tested application
  appManager.TerminateProcess(processName)

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"];
  var processName = "smartbear.example.orders";

  // Launch the tested application
  appManager["LaunchTestedApp"]();

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

  // Post the process state to the test log
  Log["Message"](appManager["ProcessState"](processName));

  // Restore the process of the tested application from the background
  appManager["ActivateProcess"](processName);

  // Terminate the process of the tested application
  appManager["TerminateProcess"](processName);

}

See Also

ApplicationManager Object

Highlight search results