---Advertisement---

Appium Desired Capabilities for Android Emulator – Complete Guide with Examples Best 2025

By Manisha

Updated On:

---Advertisement---
Appium Desired Capabilities for Android Emulator

Introduction

Appium Desired Capabilities for Android Emulator: When automating mobile apps using Appium, setting up Desired Capabilities is a crucial step. These capabilities allow you to define the behavior of the Appium server and help in initializing the automation session for Android or iOS devices.

This tutorial focuses on:

  • What are Desired Capabilities?
  • Common Android and iOS capabilities
  • How to extract app package and activity information
  • Appium integration with Android Emulator

Appium Desired Capabilities for Android Emulator: Desired Capabilities are key-value pairs used to configure the Appium server during test execution. These pairs inform the Appium server about:

  • The platform (Android/iOS)
  • Device details
  • Application package and activity
  • Automation behaviors
  • They control how the test session should behave.
  • Required to create a session with the Appium server.
  • Help Appium know what app, device, and OS version to automate.
  • Necessary to initiate WebDriver instances like AndroidDriver, IOSDriver, etc.

Example:

java

DesiredCapabilities caps = new DesiredCapabilities();

caps.setCapability(“platformName”, “Android”);

caps.setCapability(“deviceName”, “emulator-5554”);


CapabilityDescriptionExample Usage
platformNameOS platform name“Android”
deviceNameEmulator or device name“emulator-5554”
appPackageJava package name of the app“com.whatsapp”
appActivityEntry activity to be launched“com.whatsapp.Main”
appWaitPackageApp package to wait for“com.example.myapp”
appWaitActivityActivity to wait until it loads“com.example.SplashActivity”
automationNameAutomation engine name“UiAutomator2”

CapabilityDescriptionExample Value
platformNameOS platform“iOS”
deviceNameDevice model“iPhone 12”
platformVersioniOS version“14.4”
udidUnique device identifier“00008020-001D35C23488002E”
launchTimeoutTime to wait for app to launch2000

👉 Reference: Official Appium Capability Docs


Appium Desired Capabilities for Android Emulator: To automate a specific app, you need to know:

  • App Package Name
  • App Main Activity

Method 1: Using adb Command

Connect your device and run:

bash

adb shell dumpsys window | grep -E ‘mCurrentFocus|mFocusedApp’

This displays the package and activity of the currently focused app.

Method 2: Using APK Info Apps

Install tools like APK Info from Google Play Store to view:

  • App Package
  • Activity Name
  • Permissions

Appium Desired Capabilities for Android Emulator: Android uses PackageManager to manage application packages. You can retrieve app information like permissions, activities, services, etc.

Code to Access PackageManager in Android

java

PackageManager pm = getPackageManager();

PackageInfo info = pm.getPackageInfo(“com.example.myapp”, 0);

This provides:

  • App package
  • App permissions
  • Main activity

To automate tests using Appium with Maven, add dependencies in your pom.xml:

xml

<dependency>

    <groupId>io.appium</groupId>

    <artifactId>java-client</artifactId>

    <version>8.3.0</version>

</dependency>

<dependency>

    <groupId>org.seleniumhq.selenium</groupId>

    <artifactId>selenium-java</artifactId>

    <version>4.1.0</version>

</dependency>


  • Desired Capabilities are essential for Appium test setup.
  • They help initialize sessions for both Android and iOS.
  • Use tools like adb or PackageManager to fetch app info.
  • Use appPackage and appActivity to launch your target Android app.
  • For iOS automation, set capabilities like udid, platformVersion, and bundleId.

UiAutomater Viewer

👉 Official Appium Capability Docs


Leave a Comment

Index