If you are working on creating a test automation script for mobile app testing, as part of the selenium webdriver code, you need to specify the android app’s package name and launcher activity, so in this article you will know 3 simple ways as how to find android mobile app package name and launcher activity.
The selenium code where you need to provide the above details is as below:
capabilities.setCapability("appPackage", "com.android.calculator2"); // Set your application's package name. capabilities.setCapability("appActivity", "com.android.calculator2.Calculator"); // Set your application's MainActivity i.e. the LAUNCHER activity name.
Now lets see the 3 simple way as how to identify them one after the other
Way 1: Using ADB command
Assuming that your mobile emulator is up and running, otherwise start it.
- Open your command prompt
- Type command “adb logcat” and press enter
- You will see a log scrolling continuously.
- Wait till it slows down to printing more log.
- Now on your Mobile Emulator
- Navigate to any of your mobile app(say calculator) which you want to use to automate.
- You will see some new log which gets printed and you need to look for LAUNCHER as below to get the package and Launcher activity name
- Here package name is com.android.calculator2
- Launcher activity name is com.android.calculator2.Calculator
- Sometimes you will have complete Activity name, when the package is slightly different from application package name.
Way 2: Using APK Info mobile app
- Install APK info mobile app in your mobile emulator or real device
- Open the APK info app
- Search for the app you want to automate
- Hold it for couple of seconds
- A new window opens
- Select view details
- There you can see details of package name and main activity name
Way 3: Using Android Monitor in Android Studio
In the latest versions of Android studio(I was using 2.2.3 version) you have something called Android Monitor
- Open it from menu View > Tool Windows > Android Monitor
- You will be presented with the Android Monitor pane
- In your mobile emulator, open the mobile app(say calculator) you want to test automate.
- A lot of log gets printed in to the Android Monitor View pane
- There you can find the application package and launcher activity.
- Here package name is com.android.calculator2
- Launcher activity name is com.android.calculator2.Calculator
- Sometimes you will have complete Activity name, when the package is slightly different from application package name.
I hope this article might be helpful for you to identify the package name of the android mobile app along with the Launcher Activity name.
Request you to ask any queries in form of comments, we would try our best to provide solution for you.