Selenium / Webdriver is a great automation tool for browsers. It comes with a very clean API that

Technical overview

Webdriver is a great automation tool for browsers. It comes with a very clean API that describes how users can interact with a browser. The same API can be used for ios automation as well. In the end, whatever you test, as long as the user interacts with a GUI, it is always about

  1. finding an element
  2. and then interacting with the element
Using that API for ios automation has two main advantages:
  1. it is a proven and stable API that is about to become a W3C standard
  2. it decouples the remote implementation from the local client
Selenium already comes with Java, C#, Python, Ruby clients. You can reuse whichever one your comfortable with and focus on the business logic of your tests instead of having to learn a new API.

System requirements for OSX

ios-driver is built upon 2 different frameworks from Apple.

For native apps, it uses the UIAutomation framework from Apple (more here). You need xcode with an IOS SDK > 5.0.
To check if you have the correct setup:


    $ xcodebuild -showsdks


After running the above command it will return something like:


OS X SDKs:
	OS X 10.8                     	-sdk macosx10.8
	OS X 10.9                     	-sdk macosx10.9

iOS SDKs:
	iOS 7.0                       	-sdk iphoneos7.0

iOS Simulator SDKs:
	Simulator - iOS 7.0           	-sdk iphonesimulator7.0


The server is written in Java and requires Java 7.To check that you have the correct version :


    $ java -version


will return the version you're currently running, or prompt you to install it.

Getting a test application

We use an example application from Apple : InternationalMountains. You can also use any other app that will work with UIAutomation. To use the InternationalMountains app, download it from here (last built using Xcode 6.1.1), and unzip it.

You can also try UICatalog which has an example of the UI element available on iOS.

Launching ios-driver

Download ios-server-.jar

Download the latest version of the ios-server here.

Go to the folder where you downloaded the jar, and run the following command:

$ java -jar ios-server-DEFAULT-standalone.jar -aut
    path/to/aut.app -port 4444

You should see something like the following log in the terminal :


Beta features enabled ( enabled by -beta flag ): false
Simulator enabled ( enabled by -simulators flag): true
Inspector: http://0.0.0.0:4444/inspector/
tests can access the server at http://0.0.0.0:4444/wd/hub
server status: http://0.0.0.0:4444/wd/hub/status
Connected devices: http://0.0.0.0:4444/wd/hub/devices/all
Applications: http://0.0.0.0:4444/wd/hub/applications/all
Capabilities: http://0.0.0.0:4444/wd/hub/capabilities/all
Monitoring '/Users/mpalotas/Downloads/applications' for new applications
Archived apps /Users/mpalotas/Downloads/applications
using xcode install : /Applications/Xcode.app
using IOS version 7.0
ios >= 6.0. Safari and hybrid apps are supported.

Applications :
---------------
	CFBundleName=InternationalMountains,CFBundleVersion=1.1
	CFBundleName=Safari,CFBundleVersion=9537.53

2014-03-05 15:47:30.136:INFO::jetty-7.x.y-SNAPSHOT
2014-03-05 15:47:30.242:INFO::Started SelectChannelConnector@0.0.0.0:4444

Check that the application is recognized by opening a browser and navigating to : http://localhost:4444/wd/hub/status

You should see a json object with all the info about the app.


    {
    "class": "org.openqa.selenium.remote.Response",
    "hCode": 960985732,
    "sessionId": null,
    "state": null,
    "status": 0,
    "value": {
    "build": {
    "revision": "120cf4311807e2e137e519f4c4877cf6340d0cbc",
    "time": "20130927-1435",
    "version": "0.6.5"
    },
    "ios": {"simulatorVersion": "7.0"},
    "java": {"version": "1.7.0_25"},
    "os": {
    "arch": "x86_64",
    "name": "Mac OS X",
    "version": "10.9.1"
    },
    "state": "success",
    "supportedApps": [
    {
    "CFBundleDevelopmentRegion": "en",
    "CFBundleExecutable": "InternationalMountains",
    "CFBundleIconFile": "Icon.png",
    "CFBundleIdentifier": "com.yourcompany.InternationalMountains",
    "CFBundleInfoDictionaryVersion": "6.0",
    "CFBundleName": "InternationalMountains",
    "CFBundlePackageType": "APPL",
    "CFBundleSignature": "????",
    "CFBundleSupportedPlatforms": ["iPhoneSimulator"],
    "CFBundleVersion": "1.1",
    "DTPlatformName": "iphonesimulator",
    "DTSDKName": "iphonesimulator7.0",
    "LSRequiresIPhoneOS": true,
    "NSMainNibFile": "MainWindow",
    "UIDeviceFamily": [1],
    "applicationPath": "/Users/mpalotas/Downloads/InternationalMountains.app",
    "device": "iphone",
    "deviceAlt": [
    "iphone",
    "ipod"
    ],
    "device_Alt": [
    "iphone",
    "ipad"
    ],
    "resources": {"CFBundleIconFile": "/wd/hub/resources/hash=-674408620"},
    "sdkVersion": "7.0",
    "sdkVersion_Alt": [
    "5.0",
    "5.1",
    "6.0",
    "6.1"
    ],
    ...
    ...
    ...