Applies to TestComplete 14.20, last modified on September 11, 2019

In your tests you may need to run your tested iOS application. When recording a test, you can run an iOS application manually, for example, by touching the application icon on the screen of the device. However, this makes your tests dependent on certain UI elements and requires that additional user actions be recorded and played back.

To make your tests more stable, you can automate running iOS applications and start the desired application directly from your tests. This topic describes approaches you can use to start your iOS application in TestComplete.

Requirements

  • The application you launch from TestComplete must be signed with a development provisioning profile. If a distribution profile was used to sign it, you need to launch the application manually, or find a way to automate its start.

    To instrument the application in TestComplete, download the needed development provisioning profile from Apple’s Member Center and use it to instrument your application. See Get Certificate Files.

  • Your application’s .ipa file must be installed on the device before you run it. Make sure the Deploy to the device on start property of your tested application is enabled to command TestComplete to automatically install the .ipa file on the device before starting recording or running tests. This approach frees you from having to install the needed archive file manually before running tests. For more information, see Deploying iOS Applications to Devices.

Running From the Tested Applications Collection

The Tested Applications collection in TestComplete projects stores launch information on your applications under test. You can add your iOS application archive files to the collection and launch them in the same way you launch other types of tested applications - from the TestedApps editor or from tests by using the Run TestedApp operation or the TestedApps.AppName.Run method.

Note: An application is launched if its Launch application from tests property is enabled in the TestedApps editor. You can modify the value of this property in the Basic Parameters section of the TestedApps editor or from scripts.

Running From the Mobile Screen Window

If the Tested Application collection in your test project stores the launch information on your iOS application under test, you can launch that application from the Mobile Screen window.

To do this, click the Run Apps toolbar button and choose the desired tested application from the drop-down menu.

Autorunning on Recording

To command TestComplete to start an application automatically on recording, enable the Autorun application on recording option for your tested iOS application. When you start recording, the needed application will start on the device automatically.

Running From Scripts

To start any application installed on your iOS device from your scripts, use the RunApplication method of the ApplicationManager object. This method runs the specified application.

The code below demonstrates how you can use this method:

JavaScript

function Test()
{
  let appManagerObj = Mobile.Device("iPhone").ApplicationManager;
  // Retrieve application info from the device
  let appObj = appManagerObj.GetApplicationByBundleId("com.example.myapp");

  // Verify whether the application is found
  if (!strictEqual(appObj, null))
    // Run the application
    appManagerObj.RunApplication(appObj);

}

JScript

function Test()
{
  var appManagerObj = Mobile.Device("iPhone").ApplicationManager;
  // Retrieve application info from the device
  var appObj = appManagerObj.GetApplicationByBundleId("com.example.myapp");

  // Verify whether the application is found
  if (appObj != null)
    // Run the application
    appManagerObj.RunApplication(appObj);

}

Python

def Test():
  appManagerObj = Mobile.Device("iPhone").ApplicationManager;
  # Retrieve application info from the device
  appObj = appManagerObj.GetApplicationByBundleId("com.example.myapp");

  # Verify whether the application is found
  if (appObj != None):
    # Run the application
    appManagerObj.RunApplication(appObj);

VBScript

Sub Test

  Set appManagerObj = Mobile.Device("iPhone").ApplicationManager
  ' Retrieve application info from the device
  Set appObj = appManagerObj.GetApplicationByBundleId("com.example.myapp")

  ' Verify whether the application is found
  If Not appObj Is Nothing Then
    ' Run the application
    Call appManagerObj.RunApplication(appObj)
  End If

End Sub

DelphiScript

procedure Test();
var appManagerObj, appObj;
begin
  appManagerObj := Mobile.Device('iPhone').ApplicationManager;
  // Retrieve application info from the device
  appObj := appManagerObj.GetApplicationByBundleId('com.example.myapp');

  // Verify whether the application is found
  if not appObj = nill then
    // Run the application
    appManagerObj.RunApplication(appObj);

end;

C++Script, C#Script

function Test()
{
  var appManagerObj = Mobile["Device"]("iPhone")["ApplicationManager"];
  // Retrieve application info from the device
  var appObj = appManagerObj["GetApplicationByBundleId"]("com.example.myapp");

  // Verify whether the application is found
  if (appObj != null)
    // Run the application
    appManagerObj["RunApplication"](appObj);

}

Running From Keyword Tests

To run an application installed on an iOS device from a keyword test, call the ApplicationManager.RunApplication method by using the Call Object Method or Run Code Snippet operation.

See Also

Adding iOS Applications to the List of Tested Applications
Working With Tested Applications in Tests

Highlight search results