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.

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)
  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 vis 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, and also complete the configuration of WebDriverAgent.

 

 

Environment Configuration (for Appium XCUITest driver)

(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: brew.sh)

 

Install libimobiledevice and ideviceinstaller

Paste the following code at a terminal prompt:

brew install libimobiledevice --HEAD

brew install ideviceinstaller

 

Install Carthage

brew install carthage

Carthage is a framework dependency manager, and used to manage our projects’ dependencies.

 

Download and install Node.js

https://nodejs.org/en/download

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

 

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

 

 

Edit WebDriverAgent

Open the folder of WebDriverAgent.xcodeproj, then modify:

  1. WebDriverAgentLib
  2. WebDriverAgentRunner

For both of them, change the bundle idenfier, development target, and add your developer certificate.

Then build it to a Generic iOS device, or your real device.

 

 

Test it using your real deice:

Run this at the terminal:

cd  /usr/local/lib/node_modules/appium/node_modules/appium-xcuitest-driver/WebDriverAgent

 

xcodebuild -project WebDriverAgent.xcodeproj -scheme WebDriverAgentRunner -destination 'your udid' test

 

 

Run Appium with related capabilities.

So now, open the Appium desktop, enter the capabiltieis, and start the session.

Obtain developer certificate through Apple website. A personal certificate will be fine if the version of Xcode is greater than 7.

Using Xcode to configure:

WebDriverAgent and XCtestWD (Inspector): both of them need to change the signing info:

  1. WebDriverAgent and WebDriverAgent Runner: change the bundle ID to a unique one, and then add signing information. Both of the WDA and Runner need to do this. Then build it.
  2. For XCtestWD, the same thing needs to do as well: change the bundle ID, and then add signing information.

 

Change the permission of folders:

Using chmod -R 777 FilePath

 

 

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