Appium Tutorials 2: Desired Capabilities & Android Capabilities

Appium Tutorials 2: What is Desired Capabilities?

1
190

Desired Capabilities 

Desired capabilities are basically JSON object (a set of keys and values) sent by the client to the server. It describes the capabilities for the automation session in which we are interested.  We will discuss the capabilities one by one; first, we will see the Appium server’s capabilities:  

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

 

Android capabilities  

Now, let’s discuss the Android capabilities, as shown below: 

 appPackage 

 This capability is for the Java package of the Android app that you want to run, for example, 

com.android.calculator2, com.android. 

settings, and so on: 

caps.setCapability(“appPackage”, 

“com.android.calculator2”); 

 appActivity 

By using this capability, you can specify the Android activity that you want to launch from your package, for example, Main Activity, .Settings, com.android.calculator2. Calculator, and so on:  

caps. setCapability(“appActivity”, “com.android.calculator2.Calculator”);   

 appWaitActivity 

Android activity for which the user wants to wait can be defined using this capability:  

caps.setCapability (“appWaitActivity”,”com.android.calculator2.Calculator”);  

Alternatively, you can also use this command. 

 appWaitPackage 

The Java package of the Android app you want to wait for can be defined using the following capability,  

for example, com.example. 

android.myApp, com.android.settings, and 

so on: 

caps.setCapability(“appWaitPack 

age”,”com.example.android.myApp”); 

deviceReadyTimeout 

You can set the timeout (in seconds) while waiting for the device to be ready, as follows; the default value is 5 seconds: 

caps.setCapability 

(“deviceReadyTimeout”,”10″); 

 enablePerformanceLogging 

You can enable the Chrome driver’s performance logging by the use of this capability. It will enable logging only for Chrome and web view; the default value is false:  

caps.setCapability (“enablePerformanceLogging”, “true”);   

 androidDeviceReadyTimeout 

To set the timeout in seconds for a device to become ready after booting, you can use the following capability:  

caps.setCapability( “androidDeviceReadyTimeout”,”20″);   

 androidDeviceSocket 

This capability is used to set DevTools socket name. It is only needed when an app is a Chromium-embedding browser. The socket is opened by the browser and the ChromeDriver connects to it as a DevTools client, for example, chrome_DevTools_remote:  

caps.setCapability(“androidDevice Socket”,”chrome_DevTools_remote”);   

 Avd 

Using this capability, you can specify the name of avd that you want to launch, for example, AVD_ NEXUS_5:  

caps.setCapability (“avd”,”AVD_NEXUS_5″);  

 avdLaunchTimeout  

This capability will help you define how long you need to wait (in milliseconds) for an avd to launch and connect to the Android Debug Bridge (ADB) (the default value is 120000):  

caps.setCapability(“avdLaunch Timeout”,”230000″); 

 avdReadyTimeout 

You can specify the wait time (in milliseconds) for an avd to finish its boot animations using the following capability; the default wait timeout is 120000:  

caps.setCapability(“avdReady Timeout”,”240000″);   

 avdArgs  

To pass the additional emulator arguments when launching an avd, use the following capability, for example, netfast:  

caps.setCapability(“avdArgs”, “netfast”);  

 chromedriverExecutable  

You can give the absolute local path to the WebDriver executable (if the Chromium embedder provides its own WebDriver, it should be used instead of the original ChromeDriver bundled with Appium) using the following capability:  

caps.setCapability (“chromedriverExecutable”, “/abs/path/to/webdriver”);  

 autoWebviewTimeout 

The following capability allows you to set the time (in milliseconds) for which you need to wait for the Web view context to become active; the default value is 2000:  

caps.setCapability (“autoWebviewTimeout”,”3000″);   

 intentAction 

Intent action is basically used to start an activity, as shown in the following code. The default value is android.intent.action.MAIN. For example, android.intent.action.MAIN, android.intent.action.VIEW, and so on:  

caps.setCapability(“intentAction”, “android.intent.action.VIEW”);   

 intentCategory 

This provides the intent category that will be used to start the activity (the default is android. intent.category.LAUNCHER), for example, android.intent.category.LAUNCHER, android.intent.category.APP_CONTACTS:  

caps.setCapability(“intentCategory”,”android.intent.category. APP_CONTACTS”);  

 intentFlags 

Flags are used to start an activity (the default is 0x10200000), for example, 0x10200000:  

caps.setCapability(“intentFlags”, “0x10200000”);   

 unicodeKeyboard 

You can enable Unicode input by using the following code; the default value is false:  

caps.setCapability (“unicodeKeyboard”,”true”);  

  resetKeyboard 

You can reset the keyboard to its original state by using this capability. The default value is false:  

caps.setCapability (“resetKeyboard”,”true”);   

 

1 COMMENT

LEAVE A REPLY