5

is there any way to test an application which is already installed For Eg. i want to test the calculator or google map application ?

my Current Appium version is 1.3.4.1

3 Answers 3

8

Yes, you could do it. Here is sample approach to accomplish it.

1. First, get the application package name

To get the application package name, use:

adb shell 'pm list package -f' |grep calculator

note the APK file and the package name. For example:

package:/system/app/SecCalculator2/SecCalculator2.apk=com.sec.android.app.popupcalculator

the apk file is /system/app/SecCalculator2/SecCalculator2.apk and the package name is: com.sec.android.app.popupcalculator


2. Get the launch-able Activity name

First, pull the application APK's from devices:

adb pull /system/app/SecCalculator2/SecCalculator2.apk

then use aapt to get the launchable Activity name:

 aapt dump badging SecCalculator2.apk

Look for launchable-activity in the results, or use grep to filter it. The result should be similar like this:

 launchable-activity: name='com.sec.android.app.popupcalculator.Calculator'  label='Calculator' icon=''

On these sample, the launchable activity name is: .Calculator


3. Now, create the DesiredCapabilities

create your desired capability to launch the installed applications. Make sure to match the appPackage and appActivity from the steps above. (this sample is using java).

    DesiredCapabilities cap = new DesiredCapabilities();
    cap.setCapability(CapabilityType.BROWSER_NAME, "");
    cap.setCapability("platformName", "ANDROID");
    cap.setCapability("deviceName", "S5");
    cap.setCapability("platformVersion", "5.0");
    cap.setCapability("appPackage", "com.sec.android.app.popupcalculator"); 
    cap.setCapability("appActivity",".Calculator");  
    cap.setCapability("noSign", true);

And then, just create the test scripts and automate it.

2

TO know the activity name and package name of any apps simply download a apkinfo apps from playstore and get the imformation about the apk. and set to the capabilities and run your apps.

1
  • 2
    This doesn't add anything to the existing answer - could you please edit your answer to explain how this solves their problem.
    – Kate Paulk
    Mar 7, 2018 at 12:15
1

Install apk info application from Play Store and check appPackage and appActivity information, then set the same in desired capabilities:

  caps["deviceName"] = "Device Emulator"
    caps["platformVersion"] = "8.1"
    caps["platformName"] = "android"
    caps["appPackage"]= "<package>"
    caps["appActivity"] = "<activity>"
    self.driver = webdriver.Remote("http://localhost:4723/wd/hub", caps)

Your Answer

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

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