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

Hello Developer, Hope you guys are doing great. Today at Tutorial Guruji Official website, we are sharing the answer of Android phone: How to simply open an application without installation (as it is already installed) using Appium without wasting too much if your time.

The question is published on by Tutorial Guruji team.

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!

Answer

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

We are here to answer your question about Android phone: How to simply open an application without installation (as it is already installed) using Appium - If you find the proper solution, please don't forgot to share this with your team members.

Related Posts

Tutorial Guruji