iOSTestedApp Object

Applies to TestComplete 14.72, last modified on April 22, 2021

Description

The iOSTestedApp object corresponds to an iOS application in the project’s Tested Applications collection. It lets you get or set information about the iOS application, such as the path to the application's archive file (.ipa) and it also lets you launch the tested application from tests.

To obtain the iOSTestedApp object corresponding to a specific iOS application, use any of the following:

  • TestedApps.AppName, where AppName is the application's name in the Tested Applications collection and in the Project Explorer.

  • TestedApps.Items(Index), where Index is the zero-based index of the application in the Tested Applications collection.

Members

Example

The sample code below demonstrates how to add a new iOS application to the list of tested applications, specify the application’s properties and run the application.

JavaScript, JScript

function AddiOSApplication()
{

  // Sets the current device
  Mobile.SetCurrent("MyDevice");

  // Adds the iOS application from the package and obtains its index in the list of tested applications
  var ind = TestedApps.AddiOSApp("C:\\iOS\\ipas\\SampleApp.ipa");

  // Obtains the added tested application by its index and specifies its properties
  var iOSTestedApp = TestedApps.Items(ind);
  iOSTestedApp.DeployOnStart = true;
  iOSTestedApp.Launch = true;
  
  // Checks if the applications is instrumented
  if (!iOSTestedApp.Instrumented)
  {
    // Sets up backup parameters
    iOSTestedApp.BackupOriginalIPA = true;
    iOSTestedApp.BackupFileName = "C:\\iOS\\ipas\\SampleApp_ORIGINAL_BACKUP.ipa";
    // Sets up paths to certificate files
    iOSTestedApp.AppleWWDRCAPath = "C:\\iOS\\AppleWWDRCA.cer";
    iOSTestedApp.DeveloperCertPath = "C:\\iOS\\Certificates.cer";
    iOSTestedApp.DeveloperPemPath = "C:\\iOS\\Certificates.pem";
    iOSTestedApp.ProvisioningPath = "C:\\iOS\\iOS_Provisioning_Profile.mobileprovision";
    iOSTestedApp.Instrument();
  }

  // Checks if TestComplete can work with the instrumented application
  if (iOSTestedApp.InstrumentedWithSupportedVersion)
  {
    // Launches the application
    iOSTestedApp.Run();
  }
  else
  {
    // Posts an error to the log
    Log.Error("Please use uninstrumented application or application instrumented for the current TestComplete version");
  }
}

Python

def AddiOSApplication():

  # Sets the current device
  Mobile.SetCurrent("MyDevice")

  # Adds the iOS application from the package 
  # and obtains its index in the list of tested applications
  ind = TestedApps.AddiOSApp("C:\\iOS\\ipas\\SampleApp.ipa")

  # Obtains the added tested application by its index 
  # and specifies its properties
  iOSTestedApp = TestedApps.Items(ind)
  iOSTestedApp.DeployOnStart = True
  iOSTestedApp.Launch = True
  
  # Checks if the applications is instrumented
  if not iOSTestedApp.Instrumented:
    # Sets up backup parameters
    iOSTestedApp.BackupOriginalIPA = True
    iOSTestedApp.BackupFileName = "C:\\iOS\\ipas\\SampleApp_ORIGINAL_BACKUP.ipa"
    # Sets up paths to certificate files
    iOSTestedApp.AppleWWDRCAPath = "C:\\iOS\\AppleWWDRCA.cer"
    iOSTestedApp.DeveloperCertPath = "C:\\iOS\\Certificates.cer"
    iOSTestedApp.DeveloperPemPath = "C:\\iOS\\Certificates.pem"
    iOSTestedApp.ProvisioningPath = "C:\\iOS\\iOS_Provisioning_Profile.mobileprovision"
    # Instruments the application
    iOSTestedApp.Instrument()

  # Checks if TestComplete can work with the instrumented application
  if iOSTestedApp.InstrumentedWithSupportedVersion:
    # Launches the application
    iOSTestedApp.Run()
  else:
    # Posts an error to the log
    Log.Error("Please use uninstrumented application or application \
      instrumented for the current TestComplete version")

VBScript

Sub AddiOSApplication

  ' Sets the current device
  Mobile.SetCurrent("MyDevice")

  ' Adds the iOS application from the package and obtains its index in the list of tested applications
  ind = TestedApps.AddiOSApp("C:\iOS\ipas\SampleApp.ipa")

  ' Obtains the added tested application by its index and specifies its properties
  Set iOSTestedApp = TestedApps.Items(ind)
  iOSTestedApp.DeployOnStart = True
  iOSTestedApp.Launch = True
  
  ' Checks if the applications is instrumented
  If not iOSTestedApp.Instrumented Then
    ' Sets up backup parameters
    iOSTestedApp.BackupOriginalIPA = true
    iOSTestedApp.BackupFileName = "C:\iOS\ipas\SampleApp_ORIGINAL_BACKUP.ipa"
    ' Sets up paths to certificate files
    iOSTestedApp.AppleWWDRCAPath = "C:\iOS\AppleWWDRCA.cer"
    iOSTestedApp.DeveloperCertPath = "C:\iOS\Certificates.cer"
    iOSTestedApp.DeveloperPemPath = "C:\iOS\Certificates.pem"
    iOSTestedApp.ProvisioningPath = "C:\iOS\iOS_Provisioning_Profile.mobileprovision"
    ' Instruments the application
    iOSTestedApp.Instrument()
  End If

  ' Checks if TestComplete can work with the instrumented application
  If iOSTestedApp.InstrumentedWithSupportedVersion Then
    ' Launches the application
    iOSTestedApp.Run()
  Else
    ' Posts an error to the log
    Log.Error("Please use uninstrumented application or application instrumented for the current TestComplete version")
  End If
End Sub

DelphiScript

procedure AddiOSApplication();
var 
  ind, iOSTestedApp;
begin

  // Sets the current device
  Mobile.SetCurrent('MyDevice');

  // Adds the iOS application from the package and obtains its index in the list of tested applications
  ind := TestedApps.AddiOSApp('C:\iOS\ipas\SampleApp.ipa');

  // Obtains the added tested application by its index and specifies its launch properties
  iOSTestedApp := TestedApps.Items[ind];
  iOSTestedApp.DeployOnStart := true;
  iOSTestedApp.Launch := true;

  // Checks if the applications is instrumented
  if not iOSTestedApp.Instrumented then
  begin
    // Sets up backup parameters
    iOSTestedApp.BackupOriginalIPA := true;
    iOSTestedApp.BackupFileName := 'C:\iOS\ipas\SampleApp_ORIGINAL_BACKUP.ipa';
    // Sets up paths to certificate files
    iOSTestedApp.AppleWWDRCAPath := 'C:\iOS\AppleWWDRCA.cer';
    iOSTestedApp.DeveloperCertPath := 'C:\iOS\Certificates.cer';
    iOSTestedApp.DeveloperPemPath := 'C:\iOS\Certificates.pem';
    iOSTestedApp.ProvisioningPath := 'C:\iOS\iOS_Provisioning_Profile.mobileprovision';
    // Instruments the application
    iOSTestedApp.Instrument();
  end;

  // Checks if TestComplete can work with the instrumented application
  if iOSTestedApp.InstrumentedWithSupportedVersion then
    // Launches the application
    iOSTestedApp.Run()
  else
    // Posts an error to the log
    Log.Error('Please use uninstrumented application or application instrumented for the current TestComplete version');
end;

C++Script, C#Script

function AddiOSApplication()
{

  // Sets the current device
  Mobile["SetCurrent"]("MyDevice");

  // Adds the iOS application from the package and obtains its index in the list of tested applications
  var ind = TestedApps["AddiOSApp"]("C:\\iOS\\ipas\\SampleApp.ipa");

  // Obtains the added tested application by its index and specifies its properties
  var iOSTestedApp = TestedApps["Items"](ind);
  iOSTestedApp["DeployOnStart"] = true;
  iOSTestedApp["Launch"] = true;
  
  // Checks if the applications is instrumented
  if (!iOSTestedApp["Instrumented"])
  {
    // Sets up backup parameters
    iOSTestedApp["BackupOriginalIPA"] = true;
    iOSTestedApp["BackupFileName"] = "C:\\iOS\\ipas\\SampleApp_ORIGINAL_BACKUP.ipa";
    // Sets up paths to certificate files
    iOSTestedApp["AppleWWDRCAPath"] = "C:\\iOS\\AppleWWDRCA.cer";
    iOSTestedApp["DeveloperCertPath"] = "C:\\iOS\\Certificates.cer";
    iOSTestedApp["DeveloperPemPath"] = "C:\\iOS\\Certificates.pem";
    iOSTestedApp["ProvisioningPath"] = "C:\\iOS\\iOS_Provisioning_Profile.mobileprovision";
    // Instruments the application
    iOSTestedApp["Instrument"]();
  }

  // Checks if TestComplete can work with the instrumented application
  if (iOSTestedApp["InstrumentedWithSupportedVersion"])
  {
    // Launches the application
    iOSTestedApp["Run"]();
  }
  else
  {
    // Posts an error to the log
    Log["Error"]("Please use uninstrumented application or application instrumented for the current TestComplete version");
  }
}

See Also

About Tested iOS Applications
About Tested Applications
Working With Tested Applications in Tests
TestedApps Object

Highlight search results