How can an Android or iOS app be uninstalled and installed within a running WebdriverIO (WDIO) session on TestMu AI Real Device cloud?

While running mobile automation tests on the TestMu AI Real Device Cloud, there are situations where you may need to dynamically uninstall and reinstall an application during an active test session.

For example:

  • Testing fresh install behavior
  • Verifying data persistence after reinstall
  • Running tests that require app state reset
  • Validating first-launch onboarding flows

When using WebdriverIO with Appium, this can be achieved through LambdaTest custom commands executed via browser.execute().

What is the recommended way to uninstall an existing app and install a new build within the same WDIO session on the TestMu AI Real Device cloud?

Hey @bhawna_agarwal

Thanks for reaching out to us ,

Yes , you can uninstall and install apps during a running WebdriverIO session on the TestMu AI Real Device Cloud by using LambdaTest’s Appium custom hooks through browser.execute().

Below are working JavaScript examples for both operations.


Install App Example (JavaScript)

Use the lambda-install-app command to install an application dynamically.

/* Install App */
await browser.execute("lambda-install-app", {
/* Change the App URL */
appUrl: "lt://APP10160441901770316769707796",

/* Optional - retain existing app data */
retainData: true
});

Parameters

Parameter Description
appUrl LambdaTest app storage URL of the uploaded app
retainData Optional flag to retain application data

Uninstall App Example (JavaScript)

Use the lambda-uninstall-app command to remove an installed application from the device.

/* Uninstall App */

/* Change the App ID */
const APP_ID = "com.lambdatest.proverbial";
await browser.execute(`lambda-uninstall-app=${APP_ID}`);

Parameters

Parameter Description
APP_ID The package name (Android) or bundle ID (iOS) of the application

You can also take a look at the execution sample here for better understanding on Android (Execution Link) and iOS (Execution Link)

You can also refer to the official documentation on how to Ability to Install and Uninstall Apps in App Automation Scripts

Hope this helps. Feel free to reach out to us for any such queries.

Happy to help :slight_smile: