javaandroidselenium-webdriverappium-androidjava-client

Android phone: How to simply open an application without installation (as it is already installed) using Appium


Scenarios to automate is:

I installed an application and logged in successfully. There is an "App Lock" feature which closes the application. I clicked on App Lock and application is closed. Now, I need to open application again without installing and login.

In short scenario is like:
1. Install and login to application.
2. Close the application.
3. Reopen the application.

Expected result:
Application should be opened and post login screen should be displayed

Actual:
Used below capability but application is reinstalled and Sign-Up (prelogin) screen is displayed

I search for answer and found below capability but it didn't worked.

    File appDir = new File(appDirr);
    File app = new File(appDir, "appName");
    DesiredCapabilities caps = new DesiredCapabilities();
    caps.setCapability("deviceName", "Samsung Galaxy S8");
    caps.setCapability("appPackage", "appPackageName");
    caps.setCapability("appActivity", "appActivityName");
    caps.setCapability("platformName", "Android");
    caps.setCapability("app", app.getAbsolutePath());
    appiumDriver = new AppiumDriver<MobileElement>(new URL("http://0.0.0.0:4723/wd/hub"), caps);

Please let me know how can I automate this scenario.
Thanks!


Solution

  • Remove following capability:

    caps.setCapability("app", app.getAbsolutePath());//This installs the application
    

    Use this method:

    appiumDriver.activateApp(appPackage);
    

    You should know your application appPackage and appActivityName.

    appPackage and appActivityName