Skip to main content

Appium Desired Capabilities

Desired capabilities is a JSON Object sent by a client to the server. To send any desired request or to maintain any desired session with the server, a set of Key and value pair is used. JSON object is a set of keys and values. Desire capabilities describes the capabilities for the automation session.

Desired capabilities help us to modify the behavior of the server while automation. 

We need to import "import org.openqa.Selenium.remote.DesiredCapabilities" library for Java to work with the desired capabilities.

automationName: This capability is used to define the automation engine like Selendroid. Selendroid is used when you want to work with SDK version less than 17 otherwise capabilities take default value as Appium.

Example:

DesiredCapabilities caps = new DesiredCapabilities();
caps.setCapability("automationName","Selendroid"); 

This capability is not used for iOS.

platformName: This is used to set the mobile OS platform. You can set value as iOS, Android or FirefoxOS.

Example: Use either of below command.

caps.setCapability("platformName","Android");
caps.setCapability(MobileCapabilityType.PLATFORM_NAME, "Android");

platformVersion: You can set mobile OS version using this capability. 

Example: Use either of below command.

caps.setCapability("platformVersion","8.1");
caps.setCapability(MobileCapabilityType.PLATFORM_VERSION, "8.1");

deviceName: This is used to define type of emulator or device we are using.

Example: Use either of below command

caps.setCapability("deviceName", "Galaxy S7");
caps.setCapability(MobileCapabilityType.DEVICE_NAME,"Galaxy S7");

app: This is used to add absoulte local path or remote HTTP URL of the .apk, .ipa or .zip file. Example: Use either of below commands for absoulte path

Example: Use either of below commands for HTTP URL:

caps.setCapability("app","http://myapp.com/apps/myapp.apk"); 
caps.setCapability(MobileCapabilityType.APP,"http://myapp.com/apps/myapp.apk"); 

browserName: To automate mobile we application, you need to specify browser name. User Safari, Chrome, Firefox for browser values.

Example: Use either of below command

caps.setCapability("browserName", "Chrome");
caps.setCapability(MobileCapabilityType.BROWSER_NAME, "Chrome");

newCommandTimeout: Appium by default wait for 60 seconds for new command from the client and then it quit the session. You can change this time.

Example: To increase or decrease the timeout use either of the below command.

caps.setCapability("newCommandTimeout", "120");
caps.setCapability(MobileCapabilityType.NEW_COMMAND_TIMEOUT,"120");

autoLaunch: To launch and install app automatically use this capability. The default value is true check below example to set it to false:

caps.setCapability("autoLaunch","false");

language: To set the language on the simulator or emulator use below command.

caps.setCapability("language","de");

locale: To set the locale of emulator or simulator, use below command.

caps.setCapability("locale","en_IN");

udid: A unique device identifier which is used to identify iOS physical device. You can get the device id from iTunes by clicking on Serial Number and add it to below command.

caps.setCapability("udid", "1ab104387fc084g1ee224322fc022g5327fc133e");

orientation: For Landscape or Portrait orientation use below command.

caps.setCapability("orientation", "LANDSCAPE");

noRest: Use this capability to reset the app's state before the session starts; default value is false to set it to true use below command.

caps.setCapability("noReset"-," true");

fullReset: To delete entire simulator in iOS use below command. Default value is false to set it to true use below command:

caps.setCapability("fullReset", "true");
Video Tutorial

Tags

About

Elix is a premium wordpress theme for portfolio, freelancer, design agencies and a wide range of other design institutions.