Monday 2 September 2019

Settings Desired Capabilities for iOS Automation


So the question arises is, What actually are the 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. This tells the Appium drivers what kind of automation session is required.

Required Desired Capabilities to kick-off automation:


  1. Platform Name: This tells appium driver that which mobile OS platform to use.
  2. Platform Version: This tells appium driver which Mobile OS version to use.
  3. Automation Name: This tells appium driver which automation engine to use. XCUITest for iOS.
  4. Device Name: This tells appium driver which kind of mobile device to use like iPhone Simulator etc.


Sample Code for setting Desired Capabilities 


protected DesiredCapabilities generateiOSCapabilities(String application) {



DesiredCapabilities capabilities = new DesiredCapabilities();

capabilities.setCapability(MobileCapabilityType.FULL_RESET, true);

if (application.contains("SampleApp")) {
capabilities.setCapability("app", System.getProperty("user.dir") + "/apps/ios/SampleApp.app");
capabilities.setCapability(MobileCapabilityType.PLATFORM_NAME, "iOS");
capabilities.setCapability(MobileCapabilityType.PLATFORM_VERSION, "12.2");
capabilities.setCapability(MobileCapabilityType.AUTOMATION_NAME, "XCUITest");
capabilities.setCapability(MobileCapabilityType.DEVICE_NAME, "iPhone 7 Plus");
} else {
// To implement the Logger
}
capabilities.setCapability(MobileCapabilityType.NEW_COMMAND_TIMEOUT, "10");
return capabilities;
}


Here I am using a modular approach to set up the capabilities object.
Here MobileCapabilityType is an interface present in io.appium.java_client.remote package.

Description about few capablities:
FULL_RESET =true, this will delete the entire simulator folder.
NEW_COMMAND_TIMEOUT How long (in seconds) Appium will wait for a new command from the client before assuming the client quit and ending the session.

Now the question arises where I can find the information regarding the Platform Name, Platform Version and device name.
For that, you need to open a terminal
type, instruments -s devices command and press return key.

It will list down all the devices downloaded to your system as a part of Xcode.

Thanks for visiting my page, I will add more blogs to this series. 






No comments:

Post a Comment

Setting up Genymotion with Oracle Virtual Box for Android Automation

In this tutorial, we will see how to setup Genymotion with Oracle Virtual Box for Android automation. Prerequisites: Appium must ...