In the last blog we learned how to identify different elements using Appium (https://blog.knoldus.com/finding-elements-using-appium-inspector/) . In this blog we will see how we can launch any application using Appium.
It is not always possible to get the APK of the application that you want to test using Appium. For example, if we want to test any system application such as the messages app of any mobile device. You will not be able to get the APK for them. So to launch and test these applications we can you Appium.
To launch the application we need to define two desired capabilities, appPackage, and appActivity. For getting these desired capabilities we require to connect our device to the system or to launch our emulator on our local system.
- Open the terminal and execute the command:
adb devices
- This will show you all the devices connected to your local system. It can be emulator or a real device.

- Execute the command to enter into the device on which the applications is installed.
adb shell

- Now go to your mobile device and open the application for which you want to get the appActivity and appPackage. The application should be in focus for the commands to work.

- Execute the command to get the details of the focused app.
dumpsys window windows | grep -E mCurrentFocus

- The first line (com.google.android.apps.messaging) before the / is the appPackage and the line after that (com.google.android.apps.messaging.ui.ConversationListActivity) is the appActivity.
- After we get the apppackage and appActivity we can use them in our desired capabilities file.
DesiredCapabilities capability = new DesiredCapabilities();
capability.setCapability("deviceName", "Pixel_API_28");
capability.setCapability("platformVersion", "9");
capability.setCapability("platformName", "Android");
capability.setCapability("appPackage","com.google.android.apps.messaging");
capability.setCapability("appActivity","com.google.android.apps.messaging.ui.ConversationListActivity");
This was a short blog on how to launch applications without using the APK for the application.
References
