iOS Automation with Appium & Selenium

Note: This post is not up to date with latest release of Appium. An update coming soon…

Yesterday I saw a tweet on Appium release from Sauce Labs and immediately started exploring it. This post summarizes my initial experience with Appium.

Appium ( is an open source tool/framework for automating iOS Native and Hybrid Apps. It uses the WebDriver JSON wire protocol to drive iOS apps.

Appium server is written in Node.js and talks to iOS using UIAutomation via Instruments. You can use the Selenium WebDriver API for writing tests which talk to Appium via JSON wire protocol for running the Selenium commands. This also gives you advantage of writing tests in your language of preference.


I found installing Appium quite easy on a local machine. You need Node.js installed before using Appium.

1. Install Node.js from

2. Install WebDriver package for Node.js with the following command

sudo npm install wd

3. Install Appium with the following command

sudo npm install appium -g

4. Start the Appium server with the following command

appium &

Appium server will start at http://localhost:4723

Implementing test using Selenium WebDriver

I am using a sample BMI Calculator App developed with native iOS SDK for this example

Bmi Calculator App
Bmi Calculator App

Build the app using xcodebuild command (In this example the BmiCalc app)

xcodebuild -sdk iphonesimulator6.1

I am using Maven to setup a Java project for this test and here is pom.xml with the following dependencies added. For this example I have used IntelliJ IDEA. For more information on using Maven for Selenium script development refer bonus Chapter Integration with other Tools from my Selenium Testing Tools Cookbook

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns=""


And here is BmiCalcTest class

import org.junit.After;
import org.junit.Before;
import org.junit.Test;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.remote.CapabilityType;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.By;

import java.util.List;

import static org.junit.Assert.assertEquals;

public class BmiCalcTest {

    private WebDriver driver;

    public void setUp() throws Exception {

        //Appium needs the path of app build
        //Set up the desired capabilities and pass the iOS SDK version and app path to Appium
        File app = new File("/Users/upgundecha/Desktop/AppExamples/BmiCalculator/build/Release-iphonesimulator/");
        DesiredCapabilities capabilities = new DesiredCapabilities();
        capabilities.setCapability(CapabilityType.BROWSER_NAME, "iOS");
        capabilities.setCapability(CapabilityType.VERSION, "6.1");
        capabilities.setCapability(CapabilityType.PLATFORM, "Mac");
        capabilities.setCapability("app", app.getAbsolutePath());

        //Create an instance of RemoteWebDriver and connect to the Appium server.
        //Appium will launch the BmiCalc App in iPhone Simulator using the configurations specified in Desired Capabilities
        driver = new RemoteWebDriver(new URL("http://localhost:4723/wd/hub"), capabilities);

    public void testBmiCalc() throws Exception {

        //iOS controls are accessed through WebElement class
        //Locate the Height & Weight textField by their accessibility labels using
        WebElement heightTextField = driver.findElement("Height"));

        WebElement weightTextField = driver.findElement("Weight"));

        //Locate and tap on Calculate button using the click() method
        WebElement calculateButton =  driver.findElement("Calculate"));;

        //Locate all the label elements using By.tagName()
        List<WebElement> labels = driver.findElements(By.tagName("staticText"));

        //Check the calculated Bmi and Category displayed on labels
        //Label with index 8 has value of the Bmi and index 9 has the value for category

    public void tearDown() throws Exception {
        //Close the app and simulator

I really liked using Selenium WebDriver API for writing iOS tests with Appium. I can add iOS support to my existing Selenium Framework with minimal changes. Appium presently supports locating elements using the tag name (i.e type of iOS control) and accessibility labels.

Running tests in Cloud

You can also run Appium with Sauce Labs Cloud, for more details read

Overall Appium is a great tool to start with.

Getting Started –
Appium on GitHub –
Samples –
Wiki –
Google Group –!forum/appium-discuss

26 thoughts on “iOS Automation with Appium & Selenium

  1. Hi there! I’m a contributor on the Appium project and implemented large portions of the locators. There’s in fact a way to discover elements by their name (from Java this should be “By.Name()”). You should be able to either use the name of let’s say a botton (its caption, eg. “Calculate”) or if you have an accessibility label set (XCode) you can use this instead. Please note that if an accessibility label is set you will have to use it instead of the caption (UIAutomation detail).

    More comprehensive documentation to show up soon on Appium’s wiki:

    Great blog post! Cheers,

    1. Thanks Sebastian!

      Yes, worked for me with accessibility label. Updated the example. However I observed that this does not apply to staticText. When I use getText() or getAttribute(“value”) methods, it returns the accessibility label text instead of the actual value on the staticText. Please advice.


  2. Hello,
    Firstly, I would like to thank you for the post on this. I am a newbie to this but topic of mobile automation is something that is going to be hot in the next few years since mobile market is getting huge. I was just curious if it would be possible to provide a more detailed walk through for beginners? I have installed appium and ran a build but I am not sure how to properly create a folder structure with java classes in xcode. Where pom.xml should be placed? How to run test scripts on the simulator/real device?
    I apologize if my questions are stupid, I am just seeking some help to get started.

    Thank you.

    1. Hi Z,

      Glad you liked this post and thanks for the feedback. I have updated the post. I’ll be also posting a video tutorial on this soon.


  3. Hi Unmesh,

    For the past 2 days I am trying to get an idea/implementation of appium but unable to get to an end to end flow.

    I installed appium app on my mac.
    And there is something that needs to be done in the xcode.. I checked out selenium project from here.
    I opened the iwebdriver.xcodeproject file to setup the iwebdriver for the simulator/device but here I faced an issue and was unable to proceed from there on..

    Though, I have got a vague idea on this, I wasn’t able to get to an end to end flow… Hope I get some info from your end to reach my goal of automating a native app in both android & ios

    Appreciate your help!


    1. HI Anirudh,

      Once you install the Appium and get ready your application, you can drive Selenium by various ways. iWebDriver is different thing here. It is used to run web tests on iOS Device or Emulator.

      You need to setup Selenium with your choice of language. In this post I have used Java bindings for Selenium.

      I’ll be post more on this topic soon which will help you to evaluate and decide various ways you can use Appium, keep watching this space.


      1. Thanks Unmesh, will be waiting for your post.

        Also, is XCode required to run our tests through Appium?


      2. HI Anirudh,

        You don’t need to use XCode to run Selenium tests on Appium (unless you’re developing tests in Objective-C). If Java is your choice for Selenium tests, then you can use IDE’s like Eclipse or IntelliJ IDEA to develop Selenium tests and run them with Appium.

        Best, Unmesh

  4. Can you please provide some detail of how you intergrated appium into your existing selenium framework? Is all your testing done on macs?

    1. Hi dprski33,

      I am writing further posts on how to bring Selenium and Appium together, keep watching this space.

      Yes, for the illustrated test in this post I have used Appium on Mac.


  5. Hi unmesh,

    I am working on a html5 application and have been using Selenium for my multi-browser testing without any issues. Is it possible to integrate my existing selenium tests with appium and run my tests on multi-devices like IOS and Android platforms.

    Additionally, is it possible to set up Appium on a Windows application, as currently i am working on a windows platform.

    Please advise.


    1. Hi Manish,

      Appium is built for testing native apps on both platforms (but nothing stops you to test Web/HTML5 application using WebView). If you want to test native apps, then I would recommend to use Appium.

      However for testing Web/HTML apps you can use IPhoneDriver and AndroidDriver in Selenium.

      Recently Appium team has released a Windows version.


      1. I’m confused! I came to Appium because the iPhoneDriver page says:

        “If you are looking to use WebDriver with iOS mobile Safari and are currently testing only on simulators please have a look at ios-driver or appium”

        “Both of these projects are much better implementations of WebDriver for iOS” and

        “iPhone Driver (DEPRECATED)”

        So what to use for HTML5 in mobile safari?

  6. Hey Unmesh, where can I get the BMI app from. Also waiting for that video you said you’ll make. I wanted to run the exact scenario you are running and then move on to testing my app. Thank you.

  7. Hi Umesh ,

    Great work and good post. it’s working for me…. thank you …… can you share us , how to do native app testing on the Andriod OS ..


  8. Hi Unmesh
    i am using the same code as you have written in this post. But when i run the program i get the below error :

    A new session could not be created. (Original error: Instruments crashed on startup)

    I am following the following steps:

    I launched the appium server.
    I have started the iPhone simulator as well.

    But when i run the test case overtime i get the same issue..

    Please help me to resolve the issue.
    as i am stuck on this.


  9. Hi thanks for wonderful information. I needed some inputs to run the above code in eclipse. I get lots of error with import.Can u suggest me how to get rid of it.

  10. Pingback: Pasquale Hal

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your 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 )

Connecting to %s