Features

Test App Upgrades/Mid-Session App Installations

As app developers, we frequently release new versions of our applications. In most cases, users upgrade from an older version rather than installing the app from scratch. This transition often requires migrating existing user data to ensure the app functions correctly, making upgrade testing a crucial step in development. By thoroughly testing upgrades, we can confirm that the app continues to work as expected post-update.

App upgrades aren't the only scenario where installing apps during a running session is necessary. Some applications may depend on other apps to function properly. If your app interacts with another application—such as pulling data or integrating with its features — it's essential to verify that these dependencies remain intact after an upgrade.

Additionally, there are cases where you might need to delete and reinstall an app during a session. For example, if you want to test how the app behaves when a user uninstalls and reinstalls it, the mid-session install feature can facilitate this process.

(Re-)Installing apps during a test

Before you can install a new app, or a new version of the app, we encourage you to first upload your .apk/.ipa/.zip file to TestingBot Storage.

Alternatively, you can also specify a URL to an .apk/.ipa/.zip file that is publicly accessible.

During your test, you can use the mobile:installApp command to install the app on the device.

Copy code
driver.executeScript("mobile:installApp", ImmutableMap.of("appPath", "tb://<file-name>.apk|ipa|zip"));
Copy code
driver.execute('mobile:installApp', {"appPath": "tb://<file-name>.apk|ipa|zip"})
Copy code
driver.execute_script('mobile: installApp', {"appPath": "tb://<file-name>.apk|ipa|zip"})
Copy code
driver.execute_script('mobile: installApp', {"appPath" => "tb://<file-name>.apk|ipa|zip"})
Copy code
driver.ExecuteScript("mobile: installApp", new Dictionary<string, string> { { "appPath", "tb://<file-name>.apk|ipa|zip" } });

A successful installation will return the following response, which can be used to validate if the right version of the app was installed:

Copy code
{
  "packageName": "com.testingbot.test",
  "version": "2.3.1",
  "buildNumber": "116"
}

Appium will not automatically launch the app after you installed it during the test. You can launch the app manually using the followings commands after installation:

  • Android:mobile: startActivity
  • iOS:mobile: launchApp
Copy code
// Android
driver.executeScript("mobile: startActivity", ImmutableMap.of("intent", "com.testingbot.demo/.MainActivity"));
// iOS
driver.executeScript("mobile: launchApp", ImmutableMap.of("bundleId", "com.testingbot.demo"));
Copy code
// Android
driver.execute('mobile: startActivity', {intent: 'com.testingbot.demo/.MainActivity'});
//  
driver.execute('mobile: launchApp', { bundleId: 'com.testingbot.demo'});
Copy code
# Android
driver.execute_script("mobile: startActivity", {"intent": "com.testingbot.demo/.MainActivity"})
# iOS
driver.execute_script("mobile: launchApp", {"bundleId": "com.testingbot.demo"})
Copy code
# Android
@driver.execute_script("mobile: startActivity", {"intent" => "com.testingbot.demo/.MainActivity"})
# iOS
@driver.execute_script("mobile: launchApp", {"bundleId" => "com.testingbot.demo"})
Copy code
// Android
driver.ExecuteScript("mobile: startActivity", new Dictionary<string, string> { { "intent", "com.testingbot.demo/.MainActivity" } });
// iOS
driver.ExecuteScript("mobile: launchApp", new Dictionary<string, string> { { "bundleId", "com.testingbot.demo" } });

Removing your app during a test

To remove your app during a test, you can use the mobile:removeApp command.

Copy code
// Android
driver.executeScript("mobile: removeApp", ImmutableMap.of("appId", "com.testingbot.demo"));
// iOS
driver.executeScript("mobile: removeApp", ImmutableMap.of("bundleId", "com.testingbot.demo"));
Copy code
// Android
driver.execute('mobile: removeApp', {appId: 'com.testingbot.demo'});
//  
driver.execute('mobile: removeApp', { bundleId: 'com.testingbot.demo'});
Copy code
# Android
driver.execute_script("mobile: removeApp", {"appId": "com.testingbot.demo"})
# iOS
driver.execute_script("mobile: removeApp", {"bundleId": "com.testingbot.demo"})
Copy code
# Android
@driver.execute_script("mobile: removeApp", {"appId" => "com.testingbot.demo"})
# iOS
@driver.execute_script("mobile: removeApp", {"bundleId" => "com.testingbot.demo"})
Copy code
// Android
driver.ExecuteScript("mobile: removeApp", new Dictionary<string, string> { { "appId", "com.testingbot.demo" } });
// iOS
driver.ExecuteScript("mobile: removeApp", new Dictionary<string, string> { { "bundleId", "com.testingbot.demo" } });

Other app commands

Appium supports more commands to handle apps during a test, such as:

mobile: terminateApp

This will forcefully stop the app (specified by bundleId or appId) on the device.

mobile: isAppInstalled

Verifies if the app (specified by bundleId or appId) is on the device. Returns a boolean true or false.