Toggle between iOS application during AUT


     According to one recent report, smartphone users use on average 9 apps per day, and 30 apps per month. Many apps today provide value by integrating with other aspects of the mobile phone experience, even if it’s just as simple as taking photos using the device’s camera. Testing of multi-app integrations with iOS has been challenging, because Apple’s automation model allowed automation only so long as the AUT was running. The second you switched to another app to automate another part of your user flow, the automation would die. Thankfully, with Appium’s XCUITest driver (available with iOS 9.3+), we’re no longer limited to this kind of sandbox.

     There are so many kinds of multi-app flows we could experiment with, but let’s imagine a scenario involving the camera. Let’s say your app allows the user to take photos, and modifies them in some way before finally saving them to the system-wide photo library (the Camera Roll). One key verification for testing your app will be ensuring that, after performing the necessary steps in your app, the photo is newly available in the Camera Roll album of the Photos app.

     This is all possible to encode into your Appium scripts using two handy commands: mobile:launchApp and mobile:activateApp. We know that the launchApp before, in the Appium. activateApp is just the same, only the app must already have been launched; activateApp merely brings it back to the foreground. Here are examples of how we’d use these commands, by incorporating the Bundle IDs of the apps we’re dealing with (having these Bundle IDs available is a pre-requisite),

// launch the photos app (with the special bundle id seen below)
HashMap<String, Object> args = new HashMap<>();
args.put(“bundleId”, “”);
driver.executeScript(“mobile: launchApp“, args);

// re-activate that AUT (in this case The App)
args.put(“bundleId”, “io.cloudgrey.the-app”);
driver.executeScript(“mobile: activateApp“, args);

      I believe this is so simple with Appium we can really pretend we are a user and do all the things a user would do in order to check the appropriate conditions. And chances are, you have a different requirement than verifying photo saving. So the thing to take away is the principle of using mobile: launchApp and mobile: activateApp. What’s nice is that this particular strategy will work not only for simulators but also for real devices.

Try to use this logic of switch applications during your iOS Appium automation.

Reference: Appium Pro

make it perfect!

Required Software Packages for Appium Automation on Mac OS


      I observed that most of them are struggling to deal with automation for iOS in the MAC system even during the initial stage of the setup Software Package. Most of them are unaware of which package to be installed and how can be installed. The following table will help you easily configure the required software packages for automate iOS in MAC OS,

Sl. No. Software Packages What is the usage? How to install?
1 Homebrew Homebrew is a free and open-source software package management system that simplifies the installation of software on Apple’s macOS operating system 1. Open
2. Copy /usr/bin/ruby -e “$(curl -fsSL”
3. Open terminal in MAC and paste above copied command. Click enter.
2 Node Node is an open-source, cross-platform JavaScript run-time environment that executes JavaScript code outside of a browser. Here npm will get from Node. 1. Open terminal.
2. Type brew install node. Click enter
3 Appium server Appium server listen the client commands and response with actionson device side. 1. Open terminal.
2. Type npm install -g appium. Click enter
4 Appium Doctor Attempts to diagnose and fix common Node, iOS and Android configuration issues before starting Appium 1. Open terminal.
2. Type npm install -g appium-doctor. Click enter
5 Carthage It was the first dependency manager to work with Swift; in fact, Carthage itself is written in Swift! It exclusively uses dynamic frameworks instead of static libraries – this is the only way to distribute Swift binaries that are supported by iOS 8 and up. 1. Open terminal.
2. Type brew install carthage. Click enter
6 libimobiledevice In order to run our tests on real devices, we need to install libimobiledevice dependency 1. Open terminal.
2. Type brew install libimobiledevice. Click enter
7 mobiledevice mobiledevice is a command line utility for interacting with Apple’s Private Mobile Device Framework. It can be used for automating some tasks like installing and uninstalling apps on your iPhone/iPad without having to manually do it via Xcode or iTunes. You don’t need a jailbroken device! 1. Open terminal.
2. Type brew install mobiledevice. Click enter
8 Authorize-ios authorize-ios is a utility which pre-authorizes to run UIAutomation scripts on iOS devices. We need this tool for running our tests on real devices. 1. Open terminal.
2. Type npm install -g authorize-ios. Click enter
9 ios-deploy To deploy our apps to our devices by using ios-deploy. We can install and debug apps from the command line without using Xcode. 1. Open terminal.
2. Type brew install ios-deploy. Click enter
10 ideviceinstaller ideviceinstaller helps us to install, uninstall, upgrade, archive, restore and enumerate installed or archived apps. 1. Open terminal.
2. Type sudo xcode-select -r. Click enter
3. Type brew install ideviceinstaller. Click enter
11 ios_webkit_debug_proxy In order to access web views on real iOS devices, we need to install this tool. 1. Open terminal.
2. Type brew install ios-webkit-debug-proxy. Click enter
12 Maven It is used for building and managing Java-based projects by using dependencies. 1. Open terminal.
2. Type brew install maven. Click enter

     Please use all above mentioned packages prior to start scripting for iOS applications in MAC system.

make it perfect !

Different Driver Services in Selenium and Appium


     As we know that the importance of Automation is increasing day-by-day. And also most of them are looking for open source tools like Selenium and Appium. In 2017, there are some modification happened in Driver instantiation for Selenium Drivers and Appium Drivers. They are commonly using DriverServices to build and start the services for different automation sessions. Here I would like to explain important Driver Services from Selenium and Appium.

For Internet Explorer:
WebDriver driver;
InternetExplorerDriverService service = new InternetExplorerDriverService.Builder().usingDriverExecutable(new File(<path to IEdriver executable>)).usingAnyFeePort().withLogFile(new File(System.getProperty(“userdir”)+”\\Logs\\Browser_logs\\InterntExplorer_”+getCurrentDateAndTime()+”.txt”)).withLogLevel(InternetExploreDriverLogLevel.DEBUG).build();
driver = new InternetExplorerDriver(service);

For Chrome:

WebDriver driver;
ChromeDriverService chromeservices = new ChromeDriverService.Builder().usingDriverExecutable(new File(<path to chromedriver executable>)).usingAnyFreePort().withLogFile(new File(System.getProperty(“userdir”)+”\\Logs\\Browser_logs\\Chrome_”+ getCurrentDateAndTime() + “.txt”)).withVerbose(true).build();
driver = new ChromeDriver(chromeservices);

For Firefox:

WebDriver driver;
FirefoxOptions options = new FirefoxOptions();
GeckoDriverService geckodriverservice = new GeckoDriverService.Builder().usingDriverExecutable(new File(<path to geckodriver executable>)).usingAnyFreePort().withLogFile(new File(System.getProperty(“user.dir”) + “\\Logs\\Browser_logs\\Firefox”+getCurrentDateAndTime() + “.txt”)).build();
driver = new FirefoxDriver(geckodriverservice, options);

For Edge:

WebDriver driver;
EdgeDriverService edgeservice = new EdgeDriverService.Builder().usingDriverExecutable(new File(<path to edgedriver executable>)).usingAnyFreePort().withLogFile(new File(System.getProperty(“user.dir”)+”\\Logs\\Browser_logs\\Edge_”+ getCurrentDateAndTime() + “.txt”)).build();
driver = new EdgeDriver(edgeservice);

For PhantomJS:

WebDriver driver;
Capabilities caps = new DesiredCapabilities();
((DesiredCapabilities) caps).setJavascriptEnabled(true);
((DesiredCapabilities) caps).setCapability(“takesScreenshot”, true);
PhantomJSDriverService phantomjsservice = new PhantomJSDriverService.Builder().usingPhantomJSExecutable(new File(<path to phantomjs executable>)).usingAnyFreePort().withLogFile(new File(System.getProperty(“user.dir”)+”\\Logs\\Browser_logs\\PhantomJS_”+ getCurrentDateAndTime() + “.txt”)).build();
driver = new PhantomJSDriver(phantomjsservice, caps);

For Electron Rendered Applications:

WebDriver driver;
ChromeOptions options = new ChromeOptions();
ChromeDriverService chromeservices = new ChromeDriverService.Builder().usingDriverExecutable(new File(< path to chromedriver executable>)).usingAnyFreePort().withLogFile(new File(System.getProperty(“user.dir”) +”\\Logs\\Browser_logs\\Electron_”+ getCurrentDateAndTime() + “.txt”)).withVerbose(true).build();
driver = new ChromeDriver(chromeservices, options);

For Safari:

WebDriver driver;
SafariOptions options = new SafariOptions();
driver = new SafariDriver(options);

For Appium:

WebDriver driver;
AppiumDriverLocalService driverService = AppiumDriverLocalService.buildService(new AppiumServiceBuilder()
.withAppiumJS(new File()).usingDriverExecutable(new File()).withIPAddress(“″).usingPort(4723).withArgument(AndroidServerFlag.BOOTSTRAP_PORT_NUMBER,”4724″).withArgument(AndroidServerFlag.CHROME_DRIVER_PORT,”4725”).withLogFile(new File(new File( System.getProperty(“user.dir”) +”\\Appium_logs\\appiumLogs_” + getCurrentDateAndTime() + “.txt”))

For Winium (Windows Desktop Applications):

WebDriver driver;
DesktopOptions options = new DesktopOptions();
options.setApplicationPath(<path to windowsApplication>);
WiniumDriverService service = new WiniumDriverService.Builder().usingDriverExecutable(new File(< path to winiumDriver executable>)).usingPort(9999) .withLogFile(new File(System.getProperty(“user.dir”) + “\\Logs\\Windows_logs\\Win_” + getCurrentDateAndTime() + “.txt”)) .withVerbose(false).withSilent(false).buildDesktopService();
driver = new WiniumDriver(service, options);

Try to use above mentioned Driver Services in your automation scripts.

make it perfect !

Automation for iOS 9.3.x and above


     For iOS automation, Appium relies on system frameworks provided by Apple. For iOS 9.2 and below, Apple’s only automation technology was called UIAutomation, and it ran in the context of a process called Instruments. As of iOS 10, Apple has completely removed the UIAutomation instrument, thus making it impossible for Appium to allow testing in the way it used to. Fortunately, Apple introduced a new automation technology, called XCUITest, beginning with iOS 9.3. For iOS 10 and up, this will be the only supported automation framework from Apple.

     The below Machine configuration is mandatory for running Appium automation against an iOS 9.3.x device.

  • Appium: 1.6.4 and above
  • Mac OS: OS X El Capitan 10.11 and Above
  • Xcode Version: 8.0 and Above

Setting up appium-xcuitest-driver

     This is Appiun driver for iOS using XCUITest for back-end. It has the WebDriverAgent which is a WebDriver server implementation for iOS that can be used to remote control iOS devices. It allows you to launch & kill applications, tap & scroll views or confirm view presence on a screen. This makes it a perfect tool for application end-to-end testing or general purpose device automation. It works by linking XCTest framework and calling Apple’s API to execute commands directly on a device. WebDriverAgent is developed and used at Facebook for end-to-end testing and is successfully adopted by Appium.


     This package has a lot of external dependencies and we need to ensure that all those dependencies are installed properly to make this work. Below section explains the dependencies and its installations:

libimobiledevice []

Installation  :  > brew install ideviceinstaller

carthage: []

Installation  :  > brew install carthage


Installation: brew install mobiledevice

ios-deploy: []

Installation :   npm install -g ios-deploy


Installation : npm install -g deviceconsole

xcpretty: []

Installation : gem  install xcpretty


The profile can be manually associated with the project (keep in mind that this will have to be done each time the WebDriverAgent is updated).

Once you install the Appium, you will get the path node_modules/appium-xcuitest-driver/WebDriverAgentOpen WebDriverAgent.xcodeproj in Xcode and select your developmentteam for both the WebDriverAgentLib and WebDriverAgentRunner targets. This should also auto select Signing Certificate.

Selecting Signing Certificate for WebDriverAgentLib


Select Provisioning Profile for WebDriverAgentRnner [Select a Wildcard Development Provisioning file since this will work for all the bundle ids]


     Build WebDriverAgent once to verify all above steps worked. You can just build and save the xcode project [The WebDriverAgentRunner will be installed when you execute your automation script with expected capabilities] OR you can build and install the WebDriverAgentRunner on a device connected to your mac using the below command,

xcodebuild -project WebDriverAgent.xcodeproj -scheme WebDriverAgentRunner -destination ‘id=’

Now you are ready to start the automation using XCUITest framework for iOS 9.3.x above devices.

make it perfect !