Appium Desired Capabilities: What Are They and How to Launch?

Appium desired capabilities can help us modify the behavior of the server during automation. Understanding and learning how to use it is important for app automation testing. In this blog, we will dive into this concept.

What is Appium?

Appium is a cross-platform mobile automation testing tool that enables the convenient creation of automated test cases for iOS and Android platforms. It can simulate various factions within an app, such as clicking, swiping, and text input, accomplishing any actions that would typically require manual intervention.

What are Appium desired capabilities

Desired Capabilities in Appium serve as a configuration mechanism, carrying essential information in key-value pairs. Essentially, it can be understood as a map in Java, a dictionary in Python, a hash in Ruby, or a JSON object in JavaScript. When transmitted, Desired Capabilities are represented as JSON objects.

The primary purpose of Desired Capabilities is to provide the necessary context for the Appium server to execute the current test.

Key details to consider when configuring Desired Capabilities are as follows:


1. automationName: Specifies the automation engine to use, either Appium (default) or Selendroid.

2. platformName: Indicates the name of the platform being used, such as iOS, Android, or FirefoxOS.

3. platformVersion: Refers to the version number of the mobile device's operating system, for example, 7.1 or 4.4.

4. deviceName: Represents the name of the device. For Android, this can be any arbitrary name. For iOS, it can be obtained using the command "instruments -s devices."

5. udid: Provides a unique identifier for the connected physical device, which can be obtained using the command "adb devices."

6. app: Specifies the absolute local path or a remote HTTP URL pointing to an installation package (.ipa, .apk, or .zip file). Appium installs this package on the appropriate device. For Android, this parameter is not required if the appPackage and appActivity parameters are provided. This parameter is not compatible with browserName. (Often used together with the noSign property.)

7. browserName: Specifies the H5 web browser to be tested. If testing an app, this can be ignored.

8. newCommandTimeout: Represents the time (in seconds) that Appium waits for the client to send a new command before exiting or ending the session.

9. noReset: When set to true, it prevents the app's state from being reset before the current session. By default, it is set to false.

10. fullReset: (iOS) Deletes all simulator folders. (Android) To clear the app's data, the app must be uninstalled to achieve the reset effect. In Android, the app is also uninstalled after the session is completed. The default value is false.


Specific to Android, the following additional key-value pairs are commonly used:


1. appPackage: Specifies the package name of the Android app to be executed. If testing an H5 webpage, this property can be ignored.

2. appActivity: Refers to the name of the Activity to be launched from the app package. Usually, it needs to be prefixed with a dot ('.'). If testing an H5 webpage, this property can be ignored.

3. unicodeKeyboard: When set to true, it enables the use of the Unicode input method. The default value is false.

4. resetKeyboard: After using the Unicode keyboard in a Unicode test, this property, when set to true, resets the input method to its original state. If used alone, it will be ignored. The default value is false.

5. noSign: When set to true, it skips the checking and debugging signature steps for the application. Only applicable to UiAutomator and not for Selendroid. The default value is false. (Usually used together with the app property.)


Here's a simple example of using Appium desired capabilities to launch the Calculator app on an Android device:

from appium import webdriver
# Desired Capabilities for Android
desired_caps = {
    'platformName': 'Android',
    'platformVersion': '9.0',
    'deviceName': 'Android Emulator',
    'appPackage': '',   # Package name of the Calculator app
    'appActivity': '',   # Activity name of the Calculator app
    'automationName': 'Appium',   # Default automation engine
# Appium server URL (replace with your server address)
appium_server_url = ''
# Start an Appium session
driver = webdriver.Remote(appium_server_url, desired_caps)
# Perform some actions on the Calculator app
# Get the result and print it
result = driver.find_element_by_id('result').text
print(f"The result is: {result}")
# Close the Appium session


In this example, we use Appium with Python to automate the Calculator app on an Android device. By defining the Desired Capabilities, we specify essential configurations like the platform name (Android), platform version (9.0), and the Calculator app's package name and activity name. Establishing a connection to the Appium server, we launch the app on the device and proceed to interact with it by finding elements and performing actions, such as clicking buttons to perform addition. We then retrieve and print the result displayed on the Calculator app.

Final words

The fierce competition in the market pushes developers to optimize the quality of their products and provide cross-platform quality services. Based on real devices, WeTest Automation brings you fast and efficient testing solutions that simplify and accelerate the testing cycle, and help your products stand out in the market.


Latest Posts
1Exploring Valuable Test Cases in the Android Official MVP Project: A Comprehensive Guide to Unit Tes This article serves as an appendix to "Interpreting the Unit Testing of the Android Official MVP Project". This MVP project and its unit testing cases can provide many insights for our work, so it is worth giving it a quick read.
2A Comprehensive Guide to XSS Attacks and Defenses This article provides a detailed introduction to XSS(Cross Site Scripting) vulnerability attacks and defenses, including vulnerability basics, XSS fundamentals, encoding basics, XSS Payload, and XSS attack defense.
3How to Make Your Go Program Run Faster? This article is about the Go language. It primarily focuses on runtime speed, rather than development speed – these two types of speed are distinct.
4Enhancing Mobile App Quality with Crowdsourced Testing: Benefits and Key Components In this article, we will explore the benefits of employing crowdsourcing for mobile app testing and discuss the key components that contribute to successful testing, including testing on different devices, languages, and locations.
5Video Game Testing: A Fun and Profitable Way to Make Money Playing Games In this article, we will explore various avenues through which you can potentially earn a substantial income by playing games, including creating guides, writing reviews, coaching and boosting, and game testing.