Appium Desired Capabilities for Android and iOS

Screen-Shot-2016-09-28-at-11.03.39-AM

     Most of the time I observed that people facing the issues at the initial stage of running their automation scripts due to lack of knowledge in the selection of Desired Capabilities based on their Automation platform. Here, I would like to explain important Desired Capabilities for following:

  • Mobile Web Android
  • Mobile Web iOS
  • Mobile Native Android
  • Mobile Native iOS

Mobile Web Android
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability(MobileCapabilityType.PLATFORM_NAME, “Android”);
capabilities.setCapability(MobileCapabilityType.DEVICE_NAME, “name of your test device”);
capabilities.setCapability(MobileCapabilityType.PLATFORM_VERSION, “OS version of your test device”);
capabilities.setCapability(“udid”, “UDID of your test device”);
capabilities.setCapability(MobileCapabilityType.BROWSER_NAME, “Chrome”);

Mobile Web iOS
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability(MobileCapabilityType.PLATFORM_NAME, “iOS”);
capabilities.setCapability(MobileCapabilityType.DEVICE_NAME, “name of your test device”);
capabilities.setCapability(“udid”, “UDID of your test device”);
capabilities.setCapability(MobileCapabilityType.BROWSER_NAME, MobileBrowserType.SAFARI);
capabilities.setCapability(nativeWebTap, true);
capabilities.setCapability(“startIWDP”, true);
capabilities.setCapability(IOSMobileCapabilityType.START_IWDP, true);
capabilities.setCapability(“app”, “path of SAFAILAUNCHERAPPPATH”);
//SAFAILAUNCHERAPPPATH = “/usr/local/lib/node_modules/appium/node_modules/appium-ios-driver/build/SafariLauncher/SafariLauncher.app”
capabilities.setCapability(“automationName”, “XCUITest”);
capabilities.setCapability(“realDeviceLogger”, “path of DEVICECONSOLEPATH”);
//DEVICECONSOLEPATH=”/usr/local/lib/node_modules/deviceconsole/deviceconsole”

Mobile Native Android
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability(MobileCapabilityType.PLATFORM_NAME, “Android”);
capabilities.setCapability(MobileCapabilityType.DEVICE_NAME, “name of your test device”);
capabilities.setCapability(MobileCapabilityType.PLATFORM_VERSION, “OS version of your test device”);
capabilities.setCapability(MobileCapabilityType.UDID, “UDID of your test device”);
capabilities.setCapability(MobileCapabilityType.AUTOMATION_NAME, AutomationName.ANDROID_UIAUTOMATOR2);
capabilities.setCapability(MobileCapabilityType.APP, “location of your .APK”);
capabilities.setCapability(AndroidMobileCapabilityType.APP_PACKAGE, “package name of your Android application”);
capabilities.setCapability(AndroidMobileCapabilityType.APP_ACTIVITY, “activity name of your Android application”);

Mobile Native iOS
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability(MobileCapabilityType.PLATFORM_NAME, “iOS”);
capabilities.setCapability(MobileCapabilityType.DEVICE_NAME, “name of your test device”);
capabilities.setCapability(MobileCapabilityType.PLATFORM_VERSION, “OS version of your test device”);
capabilities.setCapability(MobileCapabilityType.UDID, “UDID of your test device”);
capabilities.setCapability(MobileCapabilityType.APP, “location of your .iPA or .APP”);
capabilities.setCapability(IOSMobileCapabilityType.BUNDLE_ID, “bundle ID of your iOS application”);
capabilities.setCapability(“automationName”, “XCUITest”);
capabilities.setCapability(“realDeviceLogger”, “path of DEVICECONSOLEPATH”);
//DEVICECONSOLEPATH=”/usr/local/lib/node_modules/deviceconsole/deviceconsole”

     Once you set your Desired Capabilities, next need to instantiate the drivers for Android and iOS in the following way:

For Android
WebDriver driver;
driver = new AndroidDriver(new URL(“http://127.0.0.1:4723/wd/hub”), capabilities)

For iOS
WebDriver driver;
driver = new IOSDriver(new URL(“http://127.0.0.1:4723/wd/hub”), capabilities)

Try to use above mentioned Desired Capabilities in your automation scripts.

make it perfect !

Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Create a website or blog at WordPress.com

Up ↑

%d bloggers like this: