In this tutorial, you will learn-

What is Desired Capabilities?

Extracting Packages & Activities information

What is Desired Capabilities

‘Desired Capabilities’ help us to modify the behavior of server while Automation. In Appium, it is a type of hashmap or key-value pair, used to send a command to APPIUM server. In APPIUM, all the client commands are running in the context of a session. For example, a client sent POST/session request containing JSON object to APPIUM server. Hence, to send any desired request or to maintain any desired session with the server, a set of Key and value pair is used. This is known as ‘Desired Capabilities.’ Important Role of Desired Capability-

‘DesiredCapabilities’ help the user to control the session request with the server. For example- if we want iOS session then we might set Capability as PlatformName = iOS. Or if we want Android session then we might set Capability as PlatformName = Android. ‘DesiredCapabilities’ are used to set up the Webdriver instance eg: FirefoxDriver, ChromeDriver, InternetExplorerDriver etc. DesiredCapability is very useful for Selenium Grid. Eg: It is used to access different test cases on a different browser and different operating system. Based on mentioned DesiredCapability Grid, hub will point to the corresponding node. Here, these nodes are defined using ‘set’ property method eg:- DesiredCapabilities obj = new DesiredCapabilities(); obj.setBrowserName(“firefox”); obj.setVersion(“18.0.1”); obj.setPlatform(org.openqa.selenium.Platform.WINDOWS);

A desired capability is a library defined package. Prior to use ‘DesiredCapabilities’,it should be imported from below mentioned library Org.openqa.selenium.remote.DesiredCapabilities

APPIUM supports both Android and iOS. Therefore there are a separate set of Appium server capabilities. Below table depicts some commonly used Android capabilities and its value to use- NOTE– Refer this link ‘https://appium.io/docs/en/writing-running-appium/caps/#android-only‘ to view more Android Capabilities Below table depicts some commonly used iOS capabilities and its value to use- NOTE- Refer this link ‘http://appium.io/slate/en/master/?java#ios-only ‘ to view more iOS Capabilities

Extracting Packages & Activities information

Packages are related to bundled files or classes. It gives an organized structure to modular programming. In Java, different packages are stored in a single Jar file. The user can easily call the jar file for full execution. Similar concepts followed in Mobile application development world. In Android operating system, all applications are installed in the form of JAVA packages. Hence, to extract packages path information, Android PackageManager class is used. It retrieves package and activity information of pre and post installed application. It is installed in Android devices. You can get an instance of PackageManager class By calling getPackageManager(). This method can access and manipulate the packages and related permission of the installed applications. For example –

Summary:

Desired Capability always runs on key-value pair to send command to APPIUM Server . Use ‘PackageManager’ class to extract application information in Android.