Appium: iOS automation testing environment configuration

Helpful Websites

http://appium.io/getting-started.html

Why Appium?

Appium is an open source, cross-platform test automation tool for native, hybrid and mobile web apps, tested on simulators (iOS, FirefoxOS), emulators (Android), and real devices (iOS, Android, Windows, FirefoxOS).

1. You don’t have to recompile your app or modify it in any way, due to use of standard automation APIs on all platforms.

2. You can write tests with your favorite dev tools using any WebDriver-compatible language such as Java, Objective-C, JavaScript with Node.js (in promise, callback or generator flavors), PHP, Python, Ruby, C#, Clojure, or Perl with the Selenium WebDriver API and language-specific client libraries. (So it supports all the coding languages that Selenium supports)

3. You can use any testing framework.

1. Setup on IOS

IOS Requirements

1. Appium

2. Mac OS X 10.10 or higher

3. Xcode 7.1 or higher is recommended, with command line tool and iOS SDK installed (iOS SDK usually included in Xcode. If your Xcode does not come with command line tool, please download it from iTunes)

4. Apple Developer certificate (for signings)

5. Brew, Node.js, Java

6. For demo iOS testing, we can download a demo app from Github

Note that for iOS 9.3 and higher, UI Automation will not support any more. Instead, Apple provides testers XCUITest. With XCUITest, Apple has given different class names to the UI elements which make up the view hierarchy. As Appium relies on system frameworks provided by Apple, for iOS 9.3 and greater, we need Appium 1.6 or higher which has built in support for XCUITest. (Source: https://github.com/appium/appium/blob/master/docs/en/advanced-concepts/migrating-to-xcuitest.md#scrolling-and-clicking)

Xcode Introduction

Xcode is an integrated development environment developed by Apple, and used for iOS developers to develop software for MacOS, iOS, watchOS, and tvOS. It is available via Mac App Store, and free to download after version 4.0. For iOS testing, we need Xcode to build demo application or applications that we want to test, run simulators, and also complete the configuration of WebDriverAgent.

Environment Configuration (for Appium XCUITest driver, iOS 9.3 or greater)

(Source: https://github.com/appium/appium-xcuitest-driver)

Install Homebrew

Homebrew helps testers and developers install the stuff and packages they need that Apple didn’t. After installing Homebrew, we can just use terminal (command line tool) and codes to install packages needed.

To install it, paste the following code at a terminal prompt:

/usr/bin/ruby -e “$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)”

(the code can be copied from the official website of Homebrew: http://brew.sh )

Install libimobiledevice and ideviceinstaller

libimobiledevice is a cross-platform software library that talks the protocols to support iPhone®, iPod Touch®, iPad® and Apple TV® devices.

ideviceinstaller is a system requirement for working on ios real devices. It is also a part of libimobiledevice suite of tools.

Paste the following code at a terminal prompt:

brew install libimobiledevice –HEAD

brew install ideviceinstaller

(A useful discussion around libimobiledevice and ideviceinstaller here: https://github.com/libimobiledevice/ideviceinstaller/issues/58 )

Install Carthage

brew install carthage

Carthage is a framework dependency manager, and used to manage our projects’ dependencies. Carthage is intended to be the simplest way to add frameworks to your Cocoa application. (Cocoa is Apple‘s native object-oriented application programming interface (API) for their operating system macOS.)

(For more details: https://github.com/Carthage/Carthage )

Download and install Node.js

https://nodejs.org/en/download

After installing Node.js, we can use npm to install Appium using terminal prompt.

Or,use brew and paste the following code at a terminal prompt:

brew install node

Install iOS-deploy

npm install -g ios-deploy

Install Ruby and xcpretty

gem install xcpretty

Xcpretty is a fast and flexible formatter for Xcode build. It is a utility that will transform Xcode’s output into a format that is easy to understand and browse quickly.

Install Appium 1.6.5 or above if available

npm install –g appium

This will install the latest version of Appium. Otherwise we can just define which version we want to install using e.g. npm install -g appium@1.4.2

Install Appium-XCUITest-driver dependency

/your/path/to/appium/node_modules/appium-xcuitest-driver/WebDriverAgent

mkdir -p Resources/WebDriverAgent.bundlesh

./Scripts/bootstrap.sh –d

Appium Desktop

Then download Appium desktop, which is GUI of Appium server and inspector.

Download: http://appium.io

For any question, please refer to the ReadMe on github: https://github.com/appium/appium-desktop

Edit WebDriverAgent

WebDriverAgent helps us to focus on a particular app. WebDriverAgent 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.

So normally we can get WebDriverAgent when installing Appium. But for some versions of Appium WebDriverAgent may not be there. So if required, download WebDriverAgent from

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 )

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s