Automation Digital Labs and Desired Capabilities

Automation Digital Labs and Desired Capabilities

    We know that automation testing is one of the important factors in the software testing world. Coverage of automation testing is another critical point, moreover the availability of different real devices, different brands of devices, different versions of devices, and different browsers. Modern DevOps and Quality environments require apps to be tested on hundreds of device/OS/browser combinations. Managing an in-house device-lab is expensive, resource-intensive, restrictive, and very manual. Most of the organizations are utilizing Automation Digital Labs to get all the real devices and browser under a single umbrella.

   A digital lab provides access to real devices and browsers through an automation interface with a guaranteed level of uptime, or service availability, to support Agile development of web and mobile apps. Various vendors are providing Digital Labs in the cloud. The testers and developers can use the cloud digital labs for manual as well as automation testing. In this article, I would like to share short information about various cloud digital labs like Perfecto, SeeTest, Browserstack, Sauce Labs, HeadSpin, Kobiton and TestingBot. Also, I like to share the desired capabilities used to automate and run the applications in such cloud digital labs.

     Desired Capabilities help to configure the Appium server and provide the criteria which we wish to use for running our automation script. For example, we can request the environment (emulator or real-device), which version of the operating system to run the test on, and more. Desired Capabilities are key/value pairs encoded in JSON format and are sent to the Appium Server by the Appium client when a new automation session is requested. Next, we will see the desired capabilities used in various cloud digital labs.

1. Perfecto Cloud

     Perfecto Cloud is a web-based cloud platform that helps to do manual and automation testing of mobile and web applications. Perfecto Cloud provides access to its real-devices in the lab. For that, you need to register an account with Perfecto Cloud. To get security token from your perfecto cloud > Profile > My Security. Following are the important desired capabilities:

String URL = “https:// ” + “YOUR_PERFECTO_CLOUD_URL” + “/nexperience/perfectomobile/wd/hub”;
String SECURITY_TOKEN = “YOUR_SECURITY_TOKEN”;

Desired Capabilities for Web Application

DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability(“securityToken”, SECURITY_TOKEN );
capabilities.setCapability(“platformName”, “Windows”); //You can use MAC as platformName if you are running in MAC system
capabilities.setCapability(“platformVersion”, “10”);
capabilities.setCapability(“browserName”, “Internet Explorer”);
capabilities.setCapability(“browserVersion”, “11”);
driver = new RemoteWebDriver(new URL(URL), capabilities);

Desired Capabilities for Mobile Web

DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability(“securityToken”, SECURITY_TOKEN );
capabilities.setCapability(“platformName”, “Android”); //For iOS, you have to use iOS.
capabilities.setCapability(“udid”, “DEVICE_UDID_FROM_PERFECTO”);// You will get the udid of the device from perfecto cloud.
capabilities.setCapability(“browserName”, “chrome”);//For iOS, you have to use Safari.
driver = new RemoteWebDriver(new URL(URL), capabilities);

Desired Capabilities for Mobile Native – Android

DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability(“securityToken”, SECURITY_TOKEN );
capabilities.setCapability(“platformName”, “Android”);
capabilities.setCapability(“udid”, “DEVICE_UDID_FROM_PERFECTO”);// You will get the udid of the device from perfecto cloud.
capabilities.setCapability(“app”, “YOUR_APP_LOCATION”);// Application location in perfecto cloud. If you are using application location then below appActivity capabilty not needed.
capabilities.setCapability(“appPackage”, “YOUR_APP_PACKAGE”);// Your application package name
capabilities.setCapability(“appActivity”, “YOUR_APP_ACTIVITY”);//Your application activity name
driver = new AndroidDriver<WebElement>(new URL(URL), capabilities);

Desired Capabilities for Mobile Native – iOS

DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability(“securityToken”, SECURITY_TOKEN );
capabilities.setCapability(“platformName”, “iOS”);
capabilities.setCapability(“udid”, “DEVICE_UDID_FROM_PERFECTO”);// You will get the udid of the device from perfecto cloud.
capabilities.setCapability(“app”, “YOUR_APP_LOCATION”);// Application location in perfecto cloud. If you are using application location then below bundleId capabilty not needed.
capabilities.setCapability(“autoInstrument”, true);
capabilities.setCapability(“bundleId”, “YOUR_APP_BUNDLEID”);//Your application bundle ID.
driver = new IOSDriver<WebElement>(new URL(URL), capabilities);

2. SeeTest Cloud

     Expiritest provides SaaS digital assurance lab and access to hundreds of browsers & mobile devices (physical / emulated) hosted in Experitest data centers, from anywhere at any time. It helps to do automation for both web and mobile applications. You should register in SeeTest Cloud to get the device access and ACCESS KEY. To get ACCESS KEY, go to your SeeTest cloud, click on your profile → Get Access Key. Following are the important desired capabilities:

String URL = “https:// ” + “YOUR_SEETEST_CLOUD_URL” + “/wd/hub”;
String ACCESS_KEY = “YOUR_ACCESS_KEY_FROM_SEETEST_CLOUD”;

Desired Capabilities for Web Application

DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability(“testName”, “Web Test Execution”);
capabilities.setCapability(“accessKey”, ACCESS_KEY);
capabilities.setCapability(CapabilityType.PLATFORM_NAME, “WIN8”);/You can use MAC as platformName if you are running in MAC system.
capabilities.setCapability(CapabilityType.BROWSER_NAME, BrowserType.CHROME);
capabilities.setCapability(CapabilityType.VERSION, “83”);
driver = new RemoteWebDriver(new URL(URL), capabilities);

Desired Capabilities for Mobile Web

DesiredCapabilities capabilities= new DesiredCapabilities();
capabilities.setCapability(“testName”, “Mobile Web Test Execution”);
capabilities.setCapability(“accessKey”, ACCESS_KEY);
capabilities.setCapability(“deviceQuery”, “@os=’android'”);If you are using iOS, then value should be ios for @os.
capabilities.setCapability(“deviceModel”, “samsung”);//Device model will get from SeeTest Cloud.
capabilities.setCapability(MobileCapabilityType.PLATFORM_VERSION, “8.0.0”);
capabilities.setCapability(MobileCapabilityType.UDID, “DEVICE_UDID_FROM_SEETEST”);
capabilities.setBrowserName(MobileBrowserType.CHROMIUM);//For iOS, you can use SAFARI
driver = new AndroidDriver<>(new URL(URL), capabilities);//For iOS, you can use IOSDriver instead of AndroidDriver

Desired Capabilities for Mobile Native – Android

DesiredCapabilities capabilities= new DesiredCapabilities();
capabilities.setCapability(“testName”, “Android Mobile Native Test Execution”);
capabilities.setCapability(“accessKey”, ACCESS_KEY);
capabilities.setCapability(“deviceQuery”, “@os=’android'”);
capabilities.setCapability(“deviceModel”, “samsung”);//Device model will get from SeeTest Cloud.
capabilities.setCapability(MobileCapabilityType.PLATFORM_VERSION, “8.0.0”);
capabilities.setCapability(MobileCapabilityType.UDID, “DEVICE_UDID_FROM_SEETEST”);
capabilities.setCapability(MobileCapabilityType.APP, “cloud:APP_PACKAGE_NAME/APP_ACTIVITY_NAME”);
capabilities.setCapability(AndroidMobileCapabilityType.APP_PACKAGE, “YOUR_APP_PACKAGE”);
capabilities.setCapability(AndroidMobileCapabilityType.APP_ACTIVITY, “YOUR_APP_ACTIVITY”);
driver = new AndroidDriver<>(new URL(URL), capabilities);

Desired Capabilities for Mobile Native – iOS

DesiredCapabilities capabilities= new DesiredCapabilities();
capabilities.setCapability(“testName”, “iOS Mobile Native Test Execution”);
capabilities.setCapability(“accessKey”, ACCESS_KEY);
capabilities.setCapability(“deviceQuery”, “@os=’ios'”);
capabilities.setCapability(“deviceModel”, “iphone 6”);//Device model will get from SeeTest Cloud.
capabilities.setCapability(MobileCapabilityType.PLATFORM_VERSION, “11.0”);
capabilities.setCapability(MobileCapabilityType.UDID, “DEVICE_UDID_FROM_SEETEST”);
capabilities.setCapability(MobileCapabilityType.APP, “cloud:APP_BUNDLEID”);
capabilities.setCapability(IOSMobileCapabilityType.BUNDLE_ID, “YOUR_APP_BUNDLE_ID”);
driver = new IOSDriver<>(new URL(URL), capabilities);

3. Browserstack

    BrowserStack is a cloud web and mobile testing platform that enables developers and testers to test their websites and mobile applications across on-demand browsers, operating systems, and real mobile devices. Browserstack provides different ways of testing facilities includes LIVE – interactive cross-browser testing, AUTOMATE – for automated web testing, APP LIVE – interactive mobile app testing, and APP AUTOMATE – automate mobile app testing. You have to register with the Browserstack platform. Following are the important desired capabilities:

You will get USERNAME and ACCESS_KEY from https://www.browserstack.com/accounts/settings
String USERNAME = “YOUR_BROWSERSTACK_USERNAME”;
String ACCESS_KEY = “YOUR_BROWSERSTACK_ACCESS_KEY”;
String URL = “https:// ” + USERNAME + “:” + ACCESS_KEY + “@hub-cloud.browserstack.com/wd/hub”;

Desired Capabilities for Web Application

DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability(“os”, “OS X”);//To run on Windows platform, you can use Windows as value for os.
capabilities.setCapability(“os_version”, “Catalina”);//You will get OS version from Browserstack cloud.
capabilities.setCapability(“browser”, “Safari”);
capabilities.setCapability(“browser_version”, “13.0”);
capabilities.setCapability(“browserstack.local”, “false”);
driver = new RemoteWebDriver(new URL(URL), capabilities);

Desired Capabilities for Mobile Web

DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability(“device”, “iPhone XS”);//You will get device details from Browserstack cloud
capabilities.setCapability(“os_version”, “13”);
capabilities.setCapability(“real_mobile”, “true”);
capabilities.setCapability(“browserstack.local”, “false”);
capabilities.setCapability(“browserName”, “Safari”);//In case of Android, you can use Chrome as the browserName value.
driver = new IOSDriver<WebElement>(new URL(URL), capabilities);//For Android, you can use AndroidDriver instead of IOSDriver.

Desired Capabilities for Mobile Native – Android

DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability(“device”, “Samsung Galaxy S20”);//You will get device details from Browserstack cloud
capabilities.setCapability(“os_version”, “10.0”);
capabilities.setCapability(“real_mobile”, “true”);
capabilities.setCapability(“app”, “bs://<hashed app-id>”);//You have to upload the app into Browserstack repostory and you will get the hashed app-id. 
capabilities.setCapability(“browserstack.local”, “false”);
driver = new AndroidDriver<WebElement>(new URL(URL), capabilities);

Desired Capabilities for Mobile Native – iOS

DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability(“device”, “iPhone XS”);//You will get device details from Browserstack cloud
capabilities.setCapability(“os_version”, “13”);
capabilities.setCapability(“real_mobile”, “true”);
capabilities.setCapability(“app”, “bs://<hashed app-id>”);//You have to upload the app into Browserstack repostory and you will get the hashed app-id. 
capabilities.setCapability(“browserstack.local”, “false”);
driver = new IOSDriver<WebElement>(new URL(URL), capabilities);

You can find the code snippet to upload the application into Browserstack repository and retrieve the application URL at https://journeyofquality.com/2018/03/24/browserstack-supports-mobile-native-automation/

4. Sauce Labs

     A cloud-based automated testing platform enables developers and testers to perform functional and manual tests with Selenium or Appium on web and mobile apps. It supports real and virtual devices. You have to register with Sauce Labs to get access to the devices and their capabilities. Following are the important desired capabilities:

You will get USERNAME and ACCESS_KEY from https://app.saucelabs.com/user-settings
String USERNAME = “YOUR_SAUCELABS_USERNAME”;
String ACCESS_KEY = “YOUR_SAUCELABS_ACCESS_KEY”;
String URL = “https:// ” + USERNAME + “:” + ACCESS_KEY + “@ondemand.saucelabs.com:443/wd/hub”;

Desired Capabilities for Web Application

DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability(“platform”, “macOS 10.15”);//You will get platform details from Sauce Lab cloud.
capabilities.setCapability(“browserName”, “Safari”);
capabilities.setCapability(“version”, “13.0”);
driver = new RemoteWebDriver(new URL(URL), capabilities);

Desired Capabilities for Mobile Web

DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability(“deviceName”, “iPhone XS Simulator”); //You will get device name details from Sauce Lab cloud.
capabilities.setCapability(“platformVersion”, “13.2”);
capabilities.setCapability(“platformName”, “iOS”);//You can use Android if you are running in an Android device.
capabilities.setCapability(“browserName”, “Safari”);//In case of Android, you can use Chrome as value for browserName.
driver = new IOSDriver<WebElement>(new URL(URL), capabilities);//You can use AndroidDriver instead of IOSDriver if you are running on Android device.

Desired Capabilities for Mobile Native – Android

DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability(“deviceName”, “Android GoogleAPI Emulator”);//You will get device details from Sauce Lab cloud.
capabilities.setCapability(“platformName”, “Android”);
capabilities.setCapability(“platformVersion”, “10.0”);
capabilities.setCapability(“app”, “sauce-storage:my_app.apk”);//You need to upload the Android application .APK file into Sauce Labs repository. 
driver = new AndroidDriver<WebElement>(new URL(URL), capabilities);

Desired Capabilities for Mobile Native – iOS

DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability(“deviceName”, “iPhone XS Simulator”);//You will get device details from Sauce Lab cloud.
capabilities.setCapability(“platformName”, “iOS”);
capabilities.setCapability(“platformVersion”, “13.2”);
capabilities.setCapability(“app”, “sauce-storage:my_app.zip”);//You need to upload the iOS application into Sauce Labs repository. 
driver = new IOSDriver<WebElement>(new URL(URL), capabilities);

5. TestingBot Cloud

    TestingBot has been providing one of the cloud-based Selenium and Appium and has been improving its service ever since. TestingBot providing access to over 2000 browsers and devices that you can instantly start using for Live and Automated testing. You need to register in TestingBot to get access to the TestingBot dashboard, Key, and Secret values. Following are the important desired capabilities:

You will get KEY and SECRET from https://testingbot.com/members/user/edit
String KEY= “YOUR_TESTINGBOT_KEY”;
String SECRET= “YOUR_TESTINGBOT_SECRET”;
String URL = “https:// ” + KEY+ “:” + SECRET+ “@hub.testingbot.com/wd/hub”;

Desired Capabilities for Web Application

DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability(“platform”, “WIN10”);//You will get platform details from TestingBot cloud
capabilities.setCapability(“browserName”, “IE”);
capabilities.setCapability(“version”, “11”);
capabilities.setCapability(“name”, “Web Test”);
driver = new RemoteWebDriver(new URL(URL), capabilities);

Desired Capabilities for Mobile Web

DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability(“platformName”, “iOS”);//You need to use Android in case if you are running the script on Android device.
capabilities.setCapability(“deviceName”, “iPhone 11”);//You will get device details from TestingBot cloud
capabilities.setCapability(“version”, “13.4”);
capabilities.setCapability(“browserName”, “safari”);//In case of Android, you have to use Chrome as browserName.
capabilities.setCapability(“name”, “Mobile Web Test”);
driver = new IOSDriver<WebElement>(new URL(URL), capabilities);//You have to use AndroidDriver instead of IOSDriver if you are starting session on Android devices.

Desired Capabilities for Mobile Native – Android

DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability(“platformName”, “Android”);
capabilities.setCapability(“deviceName”, “Galaxy S10”);//You will get the device details from TestingBot cloud
capabilities.setCapability(“version”, “9.0”);
capabilities.setCapability(“app”, “tb://<hashed app-id>”);//You need to upload the APK into TestingBot repository and you will get the hashed_app_id
capabilities.setCapability(“name”, “Mobile Native Android Test”);
driver = new AndroidDriver<WebElement>(new URL(URL), capabilities);

Desired Capabilities for Mobile Native – iOS

DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability(“platformName”, “iOS”);
capabilities.setCapability(“deviceName”, “iPhone 11”);//You will get the device details from TestingBot cloud
capabilities.setCapability(“version”, “13.4”);
capabilities.setCapability(“app”, “tb://<hashed app-id>”);//You need to upload the iOS app as ZIP format into TestingBot repository and you will get the hashed_app_id
capabilities.setCapability(“name”, “Mobile Native iOS Test”);
driver = new IOSDriver<WebElement>(new URL(URL), capabilities);

6. HeadSpin Device Farm 

       HeadSpin is a service that provides device farm, test automation environments, and monitoring the performance of mobile applications. You need to register in HeadSpin to get access to the device farm and the API token. Following are the important desired capabilities:

String HEADSPIN_APITOKEN = “your-api-token-here”;
String URL = “https://appium-dev.headspin.io/v0/ ” + HEADSPIN_APITOKEN + “/wd/hub”;

Desired Capabilities for Mobile Web – Android

DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability(“platformName”, “Android”);
capabilities.setCapability(“automationName”, “UiAutomator2”);
capabilities.setCapability(“deviceName”, “ANDROID_DEVICE_UDID_FROM_HEADSPIN”);
capabilities.setCapability(“udid”, “ANDROID_DEVICE_UDID_FROM_HEADSPIN”);
capabilities.setCapability(“browserName”, “chrome”);
driver = new AndroidDriver<WebElement>(new URL(URL), capabilities);

Desired Capabilities for Mobile Web – iOS

DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability(“platformName”, “iOS”);
capabilities.setCapability(“automationName”, “XCUITest”);
capabilities.setCapability(“deviceName”, “IOS_DEVICE_UDID_FROM_HEADSPIN”);
capabilities.setCapability(“udid”, “IOS_DEVICE_UDID_FROM_HEADSPIN”);
capabilities.setCapability(“browserName”, “safari”);
driver = new IOSDriver<WebElement>(new URL(URL), capabilities);

Desired Capabilities for Mobile Native – Android

DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability(“platformName”, “Android”);
capabilities.setCapability(“automationName”, “UiAutomator2”);
capabilities.setCapability(“deviceName”, “ANDROID_DEVICE_UDID_FROM_HEADSPIN”);
capabilities.setCapability(“udid”, “ANDROID_DEVICE_UDID_FROM_HEADSPIN”);
capabilities.setCapability(“appPackage”, “YOUR_APP_PACKAGE_NAME”);
capabilities.setCapability(“appActivity”, “YOUR_APP_ACTIVITY_NAME”);
driver = new AndroidDriver<WebElement>(new URL(URL), capabilities);

Desired Capabilities for Mobile Native – iOS

DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability(“platformName”, “iOS”);
capabilities.setCapability(“automationName”, “XCUITest”);
capabilities.setCapability(“deviceName”, “IOS_DEVICE_UDID_FROM_HEADSPIN”);
capabilities.setCapability(“udid”, “IOS_DEVICE_UDID_FROM_HEADSPIN”);
capabilities.setCapability(“bundleID”, “YOUR_IOS_APP_BUNDLEID”);
driver = new IOSDriver<WebElement>(new URL(URL), capabilities);

7. Kobiton Mobile Device Cloud

      Kobiton enables developers and testers to perform automated and manual testing of mobile apps and websites on real devices. Kobiton allows for instant provisioning of real devices for testing with automated or manual scripts, and also allows current on-premise devices to be plugged in to form a holistic testing cloud. You need to register in Kobiton Cloud to get access to devices and the API key. Following are the important desired capabilities:

You will get USERNAME and API_KEY from https://portal.kobiton.com/settings/keys
String USERNAME = “YOUR_KOBITON_CLOUD_USERNAME”;
String API_KEY = “YOUR_KOBITON_CLOUD_API_KEY”;
String URL = “https:// ” + USERNAME + “:” + API_KEY + “@api.kobiton.com/wd/hub”;

Desired Capabilities for Mobile Web – Android

DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability(“platformName”, “Android”);
capabilities.setCapability(“deviceName”, “Galaxy A20”);//You will get device name details from Kobiton device cloud.
capabilities.setCapability(“platformVersion”, “9”);
capabilities.setCapability(“browserName”, “chrome”);
capabilities.setCapability(“deviceGroup”, “KOBITON”);
driver = new AndroidDriver<WebElement>(new URL(URL), capabilities);

Desired Capabilities for Mobile Web – iOS

DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability(“platformName”, “iOS”);
capabilities.setCapability(“deviceName”, “iPhone XS”);//You will get device name details from Kobiton device cloud.
capabilities.setCapability(“platformVersion”, “12.4”);
capabilities.setCapability(“browserName”, “safari”);
capabilities.setCapability(“deviceGroup”, “KOBITON”);
driver = new IOSDriver<WebElement>(new URL(URL), capabilities);

Desired Capabilities for Mobile Native – Android

DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability(“platformName”, “Android”);
capabilities.setCapability(“deviceName”, “Galaxy A20”);//You will get device name details from Kobiton device cloud.
capabilities.setCapability(“platformVersion”, “9”);
capabilities.setCapability(“deviceGroup”, “KOBITON”);
capabilities.setCapability(“app”, ” kobiton-store:<your_app_name>”);//You need to upload the application into Kobiton repository and assign kobiton-store:<your_app_name> value.
driver = new AndroidDriver<WebElement>(new URL(URL), capabilities);

Desired Capabilities for Mobile Native – iOS

DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability(“platformName”, “iOS”);
capabilities.setCapability(“deviceName”, “iPhone XS”);//You will get device name details from Kobiton device cloud.
capabilities.setCapability(“platformVersion”, “12.4”);
capabilities.setCapability(“deviceGroup”, “KOBITON”);
capabilities.setCapability(“app”, ” kobiton-store:<your_app_name>“);//You need to upload the application into Kobiton repository and assign kobiton-store:<your_app_name> value.
driver = new IOSDriver<WebElement>(new URL(URL), capabilities);

     I hope you got some knowledge of various digital labs and device farm. Try to utilize all the desired capabilities of various digital labs in your automation and enjoy the script execution in the cloud.

make it perfect!

Appium Automation for Android 10

SDVRY9UqrpjkgLWnx7rFHh

      As we know that Android 10 was released in September 2019.  There is one important change to be aware of from an automation perspective, however. If the app you are testing has a target SDK version of less than 23 (Android 6.0), then when you launch it on Android 10, you might see a new permissions interstitial before your app launches those related to contacts, location, storage, SMS, microphone and camera.

     This is because of Android 10’s new, more app permissions model. Because these older apps haven’t been coded with an eye to the new permissions model, Android needs to pop up this annoying interstitial in order to make sure everything’s cool, permissions-wise. This is a slight annoyance for users, with a great gain in terms of privacy. However, it can be damaging for automation if your code isn’t expecting it. You have three options for what to do about this.

Option 1: Automate the Permissions View

     The first option is the big hammer, you could just use Appium to automate this dialog by tapping the “Continue” button. But this means you have to throw a conditional in your test code for Android 10, and potentially waste a bunch of timing waiting for a “Continue” button that doesn’t exist on versions of Android less than 10. I used this kind of logic check but it wasted my automation execution time. So I don’t recommend it.

Option 2: Update your application’s targetSdkVersion

     If you have access to your applications’ source code, or can convince your developers to do this, you could always update your applications’ targetSdkVersion to 29 (the SDK version of Android 10), and this will do away with the interstitial. Though of course, you’ll need to participate in the new permissions system, and that might require some code updates throughout the app.

Option 3: Use autoGrantPermission

     The final option is most straightforward to use the autoGrantPermissions capability. If you include this capability and set it to true, Appium will attempt to automatically grant your app all permissions from the system perspective, so that when it comes time to launch your app, Android already thinks that all permissions have been requested and accepted. You can set the capability as follows:

capabilities.setCapability(“autoGrantPermissions “, true);

OR

capabilities.setCapability(AndroidMobileCapabilityType.AUTO_GRANT_PERMISSIONS, true);

     Using this capability is nice because you might need it already (as a way to do away with dialogs popping up throughout the execution of your test), but also because you don’t need to update the app in order to use it.

    Already Appium 1.15 supports Android 10, so make sure you download it whenever you need to automate apps on this Android platform. Don’t forget to use the last option. Following are the sample Desired Capability I used to Automation Android 10 devices,

DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability(MobileCapabilityType.DEVICE_NAME, “One Plus”);
capabilities.setCapability(MobileCapabilityType.PLATFORM_NAME, “Android”);
capabilities.setCapability(MobileCapabilityType.PLATFORM_VERSION, “10”);
capabilities.setCapability(MobileCapabilityType.AUTOMATION_NAME, AutomationName.ANDROID_UIAUTOMATOR2);
capabilities.setCapability(MobileCapabilityType.NEW_COMMAND_TIMEOUT, 180);
capabilities.setCapability(“udid”, “e6916f40”);
capabilities.setCapability(MobileCapabilityType.APP,
“C:\\Users\\abc\\Test.apk”);
capabilities.setCapability(MobileCapabilityType.NO_RESET, true);
capabilities.setCapability(AndroidMobileCapabilityType.AUTO_GRANT_PERMISSIONS, true);
driver = new AndroidDriver<WebElement>(new URL(“http://0.0.0.0:4723/wd/hub&#8221;), capabilities);

Reference: Appium Pro

make it perfect!

Speed Up iOS Appium Test Automation

vector-frameworks-appium_2x

     Appium users have the question like how to speed up the iOS tests, citing the length of time it takes to start tests which use the WebDriverAgent library (all tests using the XCUITest driver).

     Most of the perceived speed of an Appium test can’t be improved due to the base speed of booting devices or the UI actions themselves. The slowest part, which users were asking how to avoid, is the initial startup of a test: the time between sending the first POST /session command and the response indicating that your test script can begin sending commands. We can call this time period the “session creation” time.

     There are desired capabilities we can specify to greatly reduce the time it takes to create a session. Appium is built to cater to a large number of devices, for use in many different situations, but we also want to make sure that it is easy to get started automating your first test. When specifying desired capabilities, Appium will analyze the state of your system and choose default values for every desired capability which you don’t specify. By being more specific, we can have Appium skip the work it does to choose the default values.

     Our first improvement is to set the app location to a file already on the host device. Then you can directly use the bundleId 

caps.setCapability(“bundleId”, “io.test.app”);

      Please ignore the remote path of your application in the code instead of that you can use the local application path, once it gets installed on the device avoid the local path and stick to use bundleId

     Running the tests, it’s easy to notice that the app gets reinstalled on the device for each test. This takes a lot of time and can be skipped. You may have certain tests which require a fresh install or need all the app data cleaned, but those tests could be put into a separate suite, leaving the majority of tests to run faster by reusing the same app. Most users should be familiar with the noReset desired capability.

 caps.setCapability(“noReset”, true)

    Appium uses the simctl command-line tool provided by Apple to match the deviceName desired capability to the udid of the device. We can skip this step by specifying the device udid ourselves.

caps.setCapability(“udid”, “009D802528AB4A1BA7C885A9F6FDBE95”);

      When loading the WedDriverAgent server, Appium loads the files from wherever XCode saved it after compilation. This location is called the “Derived Data Directory” and Appium executes an xcodebuild command in order to get the location. Below desired capability derivedDataPath allowing Appium to skip the work of calculating it:

caps.setCapability(“derivedDataPath”, “/Users/sanojs/Library/Developer/Xcode/DerivedData/WebDriverAgent-apridxpigtzdjdecthgzpygcmdkp”);

     The last optimization is to specify the webDriverAgentUrl desired capability. If specified, Appium skips a step where it checks to make sure that there are no obsolete or abandoned WebDriverAgent processes still running. The WebDriverAgent server needs to already be running at this location, so we can only use this desired capability after the first test starts the server.

caps.setCapability(“webDriverAgentUrl”, “http://localhost:8100&#8221;);

       I hope the above tips will help you to speed up the iOS automation using Appium. Please try to change your Desired Capability today to get a better speed of automation on the iOS platform.

Refer the tips to improve the speed for Android @https://journeyofquality.wordpress.com/category/speed-up-android-appium-test-automation/

Reference: Appium Pro

make it perfect!

Speed Up Android Appium Test Automation

android-automation

      There are three special capabilities available in Appium for speeding up Android test initialization (available in the latest Appium version). Also using the appPackage and appActivity desired capabilities instead of the app capability helps for speeding up Android test automation.

  1. skipDeviceInitialization
  2. skipServerInstallation
  3. ignoreUnimportantViews

     skipDeviceInitialization is available for all Android platforms, this desired capability can be passed with the boolean value true to skip installing the io.appium.settings app on the device. This special app is installed by the Appium Android Driver at the beginning of each test and is used to manage specific settings on the device, such as:

  • Wifi/data settings
  • Disabling animation
  • Setting a locale
  • IME settings

Without the io.appium.settings app, the Appium Android driver cannot automate these functions, but if the device previously had this app installed by Appium, it doesn’t need to install it again. If you know that your device is already in the proper state then you can set skipDeviceInitialization to true and skip the time it takes to reinstall it. Appium already checks if the settings app is already installed on the device, but with this capability enabled it even skips the check to see if the app is installed.

     skipServerInstallation desired capability only applies when using the UiAutomator2 automation method. The way the UIAutomator2 driver works, it installs a special server onto the device, which listens to test commands from Appium and executes them. By default, Appium installs this server onto the device at the beginning of every test session. If the value of skipServerInstallation is set to true, you can skip the time it takes to install this server. Of course, without the server on the device Appium can’t automate it, but if you know that the server was installed during a previous test run you can safely skip this step.

   ignoreUnimportantViews desired capability is not new, but it deserves to be mentioned as another way to potentially speed up Android automation tests, especially if your tests focus on finding many elements using XPath locators. Set this to true to speed up Appium’s ability to find elements in Android apps.

     Another major time-saver when it comes to Android tests is using the appPackage and appActivity desired capabilities instead of the app capability. We need to tell Appium which app to test. Usually we use the app capability, which can be a path to a .apk, .apks, or .zip file stored on your computer’s filesystem or stored on a public website. If the app under test is known to already be installed on the device (most likely from a previous test run), the app package name and main activity can be passed instead (using appPackage and appActivity desired capabilities). Skipping the time to download a large file or install it on the Android operating system leads to big savings.

Below is the sample code which explain how can we use it in your automation script:

DesiredCapabilities caps = new DesiredCapabilities();
caps.setCapability(“platformName”, “Android”);
caps.setCapability(“deviceName”, “Android Emulator”);
caps.setCapability(“automationName”, “UiAutomator2”);
// App is already installed on device, so can be launched by Package name and Activity
caps.setCapability(“appPackage”, “io.cloudgrey.the_app”);
caps.setCapability(“appActivity”, “io.cloudgrey.the_app.MainActivity”);
// Skip the installation of io.appium.settings app and the UIAutomator 2 server.
caps.setCapability(“skipDeviceInitialization”, true);
caps.setCapability(“skipServerInstallation”, true);
caps.setCapability(“ignoreUnimportantViews”, true);
driver = new AppiumDriver(new URL(“http://localhost:4723/wd/hub&#8221;), caps);

Try to practice the above mentioned methods in your Android Automation and feel the difference in execution speed.

Reference: Appium Pro

make it perfect !

AI for Appium Test Automation

Capture

     Perhaps the most buzzy of the buzzwords in tech these days is “AI” (Artificial Intelligence), or “AI/ML” (throwing in Machine Learning). To most of us, these phrases seem like magical fairy dust that promises to make the hard parts of our tech jobs go away. To be sure, AI is largely over-hyped, or at least its methods and applications are largely misunderstood and therefore assumed to be much more magical than they are.

         How you can use AI with Appium! It’s a bit surprising, but the Appium project has developed an AI-powered element finding plugin for use specifically with Appium.

          First, let’s discuss element finding plugin. In a recent addition to Appium, added the ability for third-party developers to create “plugins” for Appium that can use an Appium driver together with their own unique capabilities to find elements. As we’ll see below, users can access these plugins simply by installing the plugin as an NPM module in their Appium directory, and then using the customFindModules capability to register the plugin with the Appium server.

       The first plugin worked on within this new structure was one that incorporates a machine learning model from Test.ai designed to classify app icons, the training data for which was just open-sourced. This is a model which can tell us, given the input of an icon, what sort of thing the icon represents (for example, a shopping cart button, or a back arrow button). The application we developed with this model was the Appium Classifier Plugin, which conforms to the new element finding plugin format.

      Basically, we can use this plugin to find icons on the screen based on their appearance, rather than knowing anything about the structure of our app or needing to ask developers for internal identifiers to use as selectors. For the time being the plugin is limited to finding elements by their visual appearance, so it really only works for elements which display a single icon. Luckily, these kinds of elements are pretty common in mobile apps.

         This approach is more flexible than existing locator strategies (like accessibility id, or image) in many cases, because the AI model is trained to recognize icons without needing any context, and without requiring them to match only one precise image style. What this means is that using the plugin to find a “cart” icon will work across apps and across platforms, without needing to worry about minor differences.

         So let’s take a look at a concrete example, demonstrating the simplest possible use case. If you fire up an iOS simulator you have access to the Photos application, which looks something like this:

The Photos app with search icon

        Notice the little magnifying glass icon near the top which, when clicked, opens up a search bar:

The Photos app with search bar and cancel text

             Let’s write a test that uses the new plugin to find and click that icon. First, we need to follow the setup instructions to make sure everything will work. Then, we can set up our Desired Capabilities for running a test against the Photos app:

DesiredCapabilities caps = new DesiredCapabilities();
        caps.setCapability("platformName", "iOS");
        caps.setCapability("platformVersion", "11.4");
        caps.setCapability("deviceName", "iPhone 6");
        caps.setCapability("bundleId", "com.apple.mobileslideshow"); 

Now we need to add some new capabilities: customFindModules (to tell Appium about the AI plugin we want to use), and shouldUseCompactResponses (because the plugin itself told us we need to set this capability in its setup instructions):

HashMap<String, String> customFindModules = new HashMap<>();
      customFindModules.put("ai", "test-ai-classifier");
      caps.setCapability("customFindModules", customFindModules);
      caps.setCapability("shouldUseCompactResponses", false); 

         You can see that customFindModules is a capability which has some internal structure: in this case “ai” is the shortcut name for the plugin that we can use internally in our test, and “test-ai-classifier” is the fully-qualified reference that Appium will need to be able to find and require the plugin when we request elements with it.

Once we’ve done all this, finding the element is super simple:

driver.findElement(MobileBy.custom("ai:search")); 

           Here we’re using a new custom locator strategy so that Appium knows we want a plugin, not one of its supported locator strategies. Then, we’re prefixing our selector with ai: to let Appium know which plugin specifically we want to use for this request (because there could be multiple). Of course since we are in fact only using one plugin for this test, we could do away with the prefix (and for good measure we could use the different find command style, too):

driver.findElementByCustom("search");

           And that’s it! As mentioned above, this technology has some significant limitations at the current time, for example that it can really only reliably find elements which are one of the icons that the model has been trained to detect. On top of that, the process is fairly slow, both in the plugin code (since it has to retrieve every element on screen in order to send information into the model), and in the model itself. All of these areas will see improvement in the future, however. And even if this particular plugin isn’t useful for your day-to-day, it demonstrates that concrete applications of AI in the testing space are not only possible, but actual!

Please try to implement above mentioned AI component in your automation script.

make it perfect !

Reference: Appium Pro