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.
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.
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.
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:
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.
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.