16 Apr How to use desired capabilities to select device
Appium Desired Capabilities
Desired Capabilities are keys and values encoded in a JSON object, sent by Appium clients to the server when a new automation session is requested. They tell the Appium drivers all kinds of important things about how you want your test to work. Each Appium client builds capabilities in a way specific to the client’s language, but at the end of the day, they are sent over to Appium as JSON objects.
Select a specific device
The limitation in using a specific device is that sometimes the device may be busy running a different script or may be offline. So, Kobiton supports multiple ways to select a specific device for automation scripts. The better option for scripts running automatically is to supply the necessary device characteristics and let the Kobiton automatically pick up the device from the available devices.
When supplying the capability value, you can use a special character to generalize the capability value. For example, the following can be used:
- The asterisk (‘*’) matches any repetition of the previous character.
Therefore, if you use the “Galaxy S6*” as the device name it will match “iPhone 6″/ “iPhone 6S”/ “iPhone 6 Plus” etc. If you use the string “9.1.*” it will match 9.1.1/9.1.2/9.1.3 etc.
The following code requests that the Kobiton select an iPhone (not iPad) device running iOS 9.x.
capabilities.setCapability("platformName", "ios"); capabilities.setCapability("platformVersion", "9.*"); capabilities.setCapability("deviceName", "iPhone*");
The following code requests that the Kobiton select an available Android device running Galaxy S6, or Galaxy S6 Edge Plus with version 7.0:
capabilities.setCapability("platformName", "Android"); capabilities.setCapability("platformVersion", "7.0"); capabilities.setCapability("manufacturer", "Galaxy S6*");