InstalledPackage Property

Applies to TestComplete 15.45, last modified on December 01, 2022
The information below concerns legacy mobile tests that work with mobile devices connected to the local computer. For new mobile tests, we recommend using the newer cloud-compatible approach.

Description

The InstalledPackage property returns information about the package specified by its zero-based index.

Declaration

PackageManagerObj.InstalledPackage(Index)

Read-Only Property
PackageManagerObj An expression, variable or parameter that specifies a reference to a PackageManager object
Index [in]    Required    Integer    

Applies To

The property is applied to the following object:

Parameters

The property has the following parameter:

Index

Specifies the zero-based index of the package installed on the device. The packages are numbered from 0 to InstalledPackageCount-1.

Property Value

The PackageObject object.

Example

The code below iterates through the packages installed on the device and posts their names and paths on the device to the test log:

JavaScript, JScript

function Test()
{
  var DeviceObj = Mobile.Device("VirtualBox");
  var PackManagerObj = DeviceObj.PackageManager;
  var Num = PackManagerObj.InstalledPackageCount;
  
  for (var i = 0; i < Num; i++)
  {
    var PackObj = PackManagerObj.InstalledPackage(i);
    // Obtain the package name
    Log.Message("The package name is: " + PackObj.Name);
    // Obtain the path to the package on the device
    Log.Message("The package device path is: " + PackObj.DevicePath);
  }
  
}

Python

def Test():
  DeviceObj = Mobile.Device("VirtualBox")
  PackManagerObj = DeviceObj.PackageManager
  Num = PackManagerObj.InstalledPackageCount
  
  for i in range (0, Num - 1):
    PackObj = PackManagerObj.InstalledPackage(i)
    # Obtain the package name
    Log.Message("The package name is: " + PackObj.Name)
    # Obtain the path to the package on the device
    Log.Message("The package device path is: " + PackObj.DevicePath)

VBScript

Sub Test
  Set DeviceObj = Mobile.Device("VirtualBox")
  Set PackManagerObj = DeviceObj.PackageManager
  Num = PackManagerObj.InstalledPackageCount
  
  For i = 0 to Num - 1
    Set PackObj = PackManagerObj.InstalledPackage(i)
    ' Obtain the package name
    Call Log.Message("The package name is: " + PackObj.Name)
    ' Obtain the path to the package on the device
    Call Log.Message("The package device path is: " + PackObj.DevicePath)
  Next
  
End Sub

DelphiScript

function Test;
var DeviceObj, PackManagerObj, Num, i, PackObj: OleVariant;
begin
  DeviceObj := Mobile.Device('VirtualBox');
  PackManagerObj := DeviceObj.PackageManager;
  Num := PackManagerObj.InstalledPackageCount;
  
  for i := 0 to Num - 1 do
  begin
    PackObj := PackManagerObj.InstalledPackage(i);
    // Obtain the package name
    Log.Message('The package name is: ' + PackObj.Name);
    // Obtain the path to the package on the device
    Log.Message('The package device path is: ' + PackObj.DevicePath);
  end;
  
end;

C++Script, C#Script

function Test()
{
  var DeviceObj = Mobile["Device"]("VirtualBox");
  var PackManagerObj = DeviceObj["PackageManager"];
  var Num = PackManagerObj["InstalledPackageCount"];
  
  for (i = 0; i < Num; i++)
  {
    var PackObj = PackManagerObj["InstalledPackage"](i);
    // Obtain the package name
    Log["Message"]( "The package name is: " + PackObj["Name"] );
    // Obtain the path to the package on the device
    Log["Message"]( "The package device path is: " + PackObj["DevicePath"] );
  }
  
}

See Also

InstallPackage Method
PackageManager Object

Highlight search results