This site is in read only mode. Please continue to browse, but replying, likes, and other actions are disabled for now.
5 / 5
Jan 2019

I have two android devices
1) Android 4.4.2
2) Android 4.2.2

Can by code where appium server can detect which desired capability it has to used.

ex i have two capabilities method for 4.4.2 and 4.2.2 now when i run appium will get the current android OS version and then trigger the suitable capabilities method

It will help in making test cases more generic and more dynamic

  • created

    Apr '15
  • last reply

    Jan '19
  • 4

    replies

  • 2.7k

    views

  • 3

    users

You can get all capabilities thought method driver.getCapabilities()
As all capabilities are a Map (key and value) get the capabilities asMap()
The desired capabilities are a map inside the capabilities map, so you need to get that (desired is the key) and put in another Map
After that get the capability you want

To show the platform version see this code snippet in Java:

Capabilities cap = driver.getCapabilities();
Map<String, ?> desired = (Map<String, ?>) cap.getCapability("desired");
System.out.println(desired.get("platformVersion"));

thanks for reply

but i want to set desired capabilities before executing the code like when i run the code. code should itself detect the android version after that it set the desired capabilities

In this case if you want to set the desired capabilities (like the android version) and rout to appropriate devices you need to use Selenium Grid.

3 years later