7

For mobile application automation I am using appium and in that following things are mandatory:

    WebDriver wd;
    File app=new File("Path\\to\\WhatsApp.apk");
    DesiredCapabilities dc=new DesiredCapabilities();
    dc.setCapability(CapabilityType.BROWSER_NAME,"");
    dc.setCapability("deviceName", "MOTO X");
    dc.setCapability("plateformVersion", "4.4.4");
    dc.setCapability("platformName", "Android");
    dc.setCapability("app", app.getAbsolutePath());     

    dc.setCapability("appPackage", "com.whatsapp");
    dc.setCapability("appActivity", "com.whatsapp.Main");

    URL url=new URL("http://127.0.0.1:4723/wd/hub");
    wd=new AndroidDriver(url, dc);

That is OK for whatsapp as we can easily get but i wanted to know that how could i know any activityname for default contact dialler,camera or any other default inbuilt functionality? Also how could i know xpath/id (like we do get in browser) in mobile app? Is there any one who could help me with that? i am just beginner to appium.Thanks!

2

6 Answers 6

2

Use UIAutomator. This will give you package name of currently active app. UIAutomator can be found at Android/sdk/tools/ .After launching UIAutomator, click on device screenshot button. But make sure, your device is connected to your system and debug mode is enabled. For Camera app, it gives package name as com.sec.android.app.camera

1

It's pretty simple, assuming you have your android SDK properly set up.

Steps to follow:

  1. Go to the terminal (command line)
  2. Then type aapt d --values badging <path-to-apk-name>

This will basically print out the info out of the androidmanifest.xml file. You can locate the package name at the top of the contents of the file displayed.Then if you scroll further down the screen, you will find launchable-activity, which displays the name the name of the main activity.

P.S. - If you have any further doubts, feel free to contact me.

0

For finding the application package and Activities you can use the App info application from google play store https://play.google.com/store/apps/details?id=de.migali.soft.apkinfo

0

Another great option is to use the hierarchyviewer tool. Look at SDK/tools. Just open it and then open the app in the device or emulator. example: com.android.launcher/com.android.launcher2.Launcher before / is the package, after / is the activity.

2
  • 1
    I'm not an android guy, but why doesn't this answer the question? It appears to be an alternative way to gather the same information, unless there's something I'm missing.
    – corsiKa
    Jan 8, 2016 at 16:37
  • Based on my research, this is a valid answer. It's a bit light on detail and could be improved, but using the Hierarchy Viewer tool does appear to be a valid way to retrieve the package name and main activity.
    – Kate Paulk
    Apr 24, 2017 at 16:53
0

1) From Google Play Store, Search and Install "Apk Info free" app.

2) Launch Apk Info free app and you can grab packge name & app activity of your targeted application

3) Ui Automator is there for finding xpath and id of an element but it supports or works only on MAC system, for windows u must communicate with ur develelopers.

1
  • Both the answers have already been given. Oct 7, 2015 at 15:18
0

Here is an article that describes two different ways to find appPackage and appActivity.

I personally used the first technic and it's working pretty well. Here is what you should do:

  1. Connect your phone to your computer.

  2. On your phone, open the app you want to know the appPackage and appActivity of.

  3. On your computer, open a shell and type adb shell

  4. On this same shell, type dumpsys window | grep -E 'mCurrentFocus'

Here are the results you should be obtaining:

mCurrentFocus=Window{c838a23 u0 appPackageName/appActivityName}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.