• Skip to main content
  • Skip to primary sidebar

AutomationTestingHub

Selenium, Appium, Cucumber and more !!!

2 Ways to find appPackage and appActivity name of your App

March 20, 2023 by anish 24 Comments

How Appium identifies your mobile app

When you write test scripts with Appium, it usually involves launching an app first and then performing some actions on it. For example, let us suppose that you are testing WhatsApp. And your test case is to verify that you can send and receive messages. To test this, your code would first launch WhatsApp and then it would verify your test case.

But how do you launch WhatsApp with Appium? Or to put this question in a different way, how would Appium recognize which app on your phone is WhatsApp? You might have tens of apps installed on your mobile device. Hence, Appium needs to identify the correct app and then open it.

Let us first see how you would do this manually? You would scroll through the list of apps installed on your phone, and then you will open the app which has the name ‘WhatsApp’. Well, Appium also follows a similar process. When you write your code, you would need to provide the name of the app, and Appium would then launch that app.

Things get a little technical here. You just can’t provide the app name as ‘WhatsApp’ in your Appium code. Internally, all the mobile apps use a different technical name. You would need to provide this technical name (also known as package name). Together with this package name, you will also need to provide the activity name of the app.

Provide appPackage and appActivity name to Appium

This article lists down 2 different methods using which you can find appPackage and appActivity names of your app under test. You can use any of these methods to find out the package and activity names of your app. Before we start with these 2 methods, let’s first get some more detail about appPackage and appActivity.

What is appPackage and appActivity name ?

appPackage:

In very basic terms, appPackage is the technical name of the app provided by its developers. It’s actually the top level package under which all the code for the app resides.

For example, appPackage for ‘YouTube’ for Android is ‘com.google.android.youtube’. For Facebook, this name is ‘com.facebook.katana’ and for WhatsApp, the appPackage is – ‘com.whatsapp’. So if you want to launch Facebook from Appium, you would need to provide it’s name as ‘com.facebook.katana’ in Appium.

appActivity:

Again, speaking in very basic terms appActivity refers to the different functionalities that are provided by the app.

For example, WhatsApp provides multiple functionalities such as chats, status, calls, setting profile photo, etc. Each of these functionalities are represented by an appActivity.

Together with these activities, every app has a main activity which is sort of the main screen you see when you launch the app. For WhatsApp, it is the Chats window, and for Facebook it would be the Wall. When you launch the app with Appium, it needs to know which activity has to be launched. And you would need to provide the main activity name (the activity which represents the app’s main screen)

With this basic and important understanding on about app package and app activity, let us start with the different methods with which you can identify this information of your app.

Which app are we going to use in our Tutorial series?

With our Appium Tutorial series, we are trying to keep things very simple so that its easier for Appium beginners to follow our articles. Keeping this in mind, we use the Google Play Store and find its appPackage & appActivity name. The main reason for using this app is that it’s available on all android mobile devices.

Google Play Store app

Let us now start with the first method on how to identify the appPackage and appActivity name for Play Store app.

Method 1: Using ‘mCurrentFocus’ or ‘mFocusedApp’ in Command Prompt

Step 1: Unlock your mobile device and connect it to your computer using USB cable

Step 2: Open Command Prompt and run ‘adb devices’ command. We are running this command to just make sure that your mobile is properly connected.

Step 3: Once you run ‘adb devices’ command, you should see that it displays the list of attached devices as shown in the below image (the actual device name that you see would be different based on what mobile phone you use) –

finding appPackage and appActivity for android devices

Step 4: Run ‘adb shell’ command. After running this command, the command prompt should look something like this –

finding appPackage and appActivity using shell command

Step 5: Now in your mobile phone, open the app for which you want to find the appPackage and appActivity. Since we are doing this for Play Store, hence we will open “Play Store” on our mobile phone.

playstore application launch

Note: Please make sure that you open the app before going to the next step, because command in the next step would provide the details only for the app which is currently in focus.

Step 6: Now run this command: dumpsys window displays | grep -E ‘mCurrentFocus’

Step 7: The above command would display the details of the app which is currently in focus. From that, you can figure out the appPackage and appActivity name as per the below image –

command mCurrentFocus to find the appPackage and appActivity

appPackage starts with com. and ends before backshash (/). So from the above image, appPackage name is – com.android.vending

appActivity starts after the backslash (/) and goes till the end. From the above image, appActivity name is – com.android.vending.AssetBrowserActivity

Step 8: There is one more similar command that provides the appPackage and appActivity name. This command adds some additional details before and after the package name & activity name, but you can still try it out just to verify that the results from the above command are same. This command is – dumpsys window displays | grep -E ‘mFocusedApp’ and the output of this command is shown below –

using command mFocusedApp to find appPackage and appActivity

In this example, where we used mFocusedApp, appActivity name is shown as a relative name, i.e., it doesn’t start with com. In such cases, you would need to add com…. at the beginning to get the complete activity name. So in our case, complete activity name for .AssetBrowserActivity would be com.android.vending.AssetBrowserActivity

Method 2: Using APK Info app

APK Info is an app which you can download from Play Store, and it will provide the appPackage and appActivity name of any app which is installed on your mobile device.

Step 1: Download “APK Info” app from Google Play Store on your android mobile.

APK Info app installed

Step 2: Once you have successfully installed APK Info app, open it and check that it lists down all the apps that you have on your phone. Then search for “Google Play Store” in the search pane as shown below

google play store app search in APK Info

Step 3: Long press on the “Google Play Store” application icon inside the APK Info app till it displays the list of options as shown below –

google playstore long press to get options for application details

Step 4: Click the option “Detailed Information” option. It would show the detailed log for the app.

Here, check the APK path section. This sections displays the “appPackage” name as highlighted in red block in the below image –

under APK path find the appPackage name

Note: Skip any number at the postfix of the name (eg: here its “-2”). So, the appPackage name in this case is – com.android.vending

Step 5: Then to find the appActivity name of the app, scroll down to the sub-section “Activities”. This sub-section displays all the activities that are available for the app. From this list, you have to look for the activity which has “MainActivity” or “Main” or “Login” in the activity name.

appActivity-Name

Here “com.google.android.finsky.activities.MainActivity” is the appActivity name for the Play Store app.

Since Play Store is a full fledged app, so it contains a lot of activities. However, if you are testing a small app or some app which is in development phase, then it would not contain these many activities. So it would be easier to identify the main activity in that case. If you still find it difficult to identify the main activity, then you can always check back with your developers or use the first method that we have provided in this article.

With this, we complete our article on identifying appPackage and appActivity name for the app you want to test. Let us know if you face any issues while identifying these properties of any particular app with these methods. We would also love to hear from you, if you have any feedback for us, or if you have any other way which can help identify these properties.

We are continuously adding more articles to our tutorial series. You can check it out here – Appium Tutorials

Filed Under: Appium

Primary Sidebar

Automation Testing Hub

Tutorials Guide

Write test scripts in BDD format using our Cucumber Selenium Tutorial

Use our Appium Tutorial Series to setup Appium from scratch

Categories

  • Android
  • Appium
  • Cucumber
  • Java
  • Playwright
  • Selenium
  • Tosca

Recent Posts

  • Appium Inspector – Download and Install
  • How to download Chromedriver for Selenium
  • Run Playwright tests on different browsers
  • Playwright Automation Testing Tutorial
  • Selenium IDE Chrome Download

Recent Comments

  • Run Playwright tests on different browsers - AutomationTestingHub on Playwright Automation Testing Tutorial
  • Confluence: CPSSoft Test Framework on Appium Inspector – Download and Install
  • Playwright Automation Testing Tutorial - AutomationTestingHub on Download and Install – Node.js and NPM
  • Chrome浏览器在使用Java的Appium中无法启动。 | JAVA语言的经验与见解 on 2 Ways to find appPackage and appActivity name of your App
  • Appium Inspector Tutorial - AutomationTestingHub on Download and Install Appium 2 Server

Archives

  • January 2024
  • July 2023
  • March 2023
  • February 2023
  • May 2018
  • April 2018
  • March 2018
  • February 2018
  • January 2018
  • November 2017
  • October 2017
  • September 2017
  • August 2017
  • July 2017
  • June 2017
  • May 2017
  • April 2017
  • March 2017
  • November 2016
  • October 2016
  • September 2016
  • August 2016
  • July 2016
  • June 2016

Latest Selenium 3 Guide

Are you using the latest version of Selenium WebDriver? It provides lot better support for the latest browser versions. Check it out here - Setup Latest Selenium WebDriver

Categories

  • Android
  • Appium
  • Cucumber
  • Java
  • Playwright
  • Selenium
  • Tosca

Copyright © 2025 · Genesis Sample on Genesis Framework · WordPress · Log in

Go to mobile version