
📌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
📌What are Desired Capabilities in Appium?
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
Why Are Desired Capabilities Important?
- 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”);
📌Commonly Used Appium Desired Capabilities for Android
Capability | Description | Example Usage |
platformName | OS platform name | “Android” |
deviceName | Emulator or device name | “emulator-5554” |
appPackage | Java package name of the app | “com.whatsapp” |
appActivity | Entry activity to be launched | “com.whatsapp.Main” |
appWaitPackage | App package to wait for | “com.example.myapp” |
appWaitActivity | Activity to wait until it loads | “com.example.SplashActivity” |
automationName | Automation engine name | “UiAutomator2” |
📌Appium Desired Capabilities for iOS Devices
Capability | Description | Example Value |
platformName | OS platform | “iOS” |
deviceName | Device model | “iPhone 12” |
platformVersion | iOS version | “14.4” |
udid | Unique device identifier | “00008020-001D35C23488002E” |
launchTimeout | Time to wait for app to launch | 2000 |
👉 Reference: Official Appium Capability Docs
📌How to Extract App Package & Activity Information
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
📌What is Android PackageManager?
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
📌Appium with Maven Setup (Optional Integration)
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>
📌Summary
- 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.
👉 Official Appium Capability Docs