Appium: A Cross-browser Mobile Automation Tool

Appium is an open source test automation tool developed and supported by Sauce Labs to automate native and hybrid mobile apps. It uses JSON wire protocol internally to interact with iOS and Android native apps using the Selenium WebDriver.

There are many other automation tools available in market to automate mobile native apps like MonkeyTalk, KIF, Calabash and Frank but most of those tools require an extra agent needs to be compiled with your application code so that the tool can interact with the mobile app. So here the problem is the app which you will be testing is not the same app which you will be submitting in the App Store as you would need to remove those automation agent libraries before submitting the app.

Automating hybrid and native mobile applications for Android and iOS is a key function handled by Appium, a node.js server. One of the core tenets of Appium is that test codes can be written in any framework or language like Ruby on Rails, C# and Java without having to modify the apps for automation purposes. The interaction between node.js server and Selenium client libraries is what ultimately works together with the mobile application. Appium is open source and can seamlessly run on a variety of devices and emulators making it an apt choice for mobile test automation.

At present Appium only supports Android and iOS based apps but support for Firefox mobile OS is in pipeline.

Appium’s Architecture

Appium is an HTTP server written in node.js which creates and handles multiple WebDriver sessions for different platforms like iOS and Android.

Appium starts a “test case” on the device that spawns a server and listens for proxied commands from the main Appium server. It is almost same as Selenium server which perceives http requests from selenium client libraries and it handles those requests in different ways depending upon the platforms. Each vendor like iOS and Android have a different way and mechanism to run a test case on the device so Appium kind of hacks in to it and run this testcase after listening commands from appium server.

How Appium works in iOS:

On iOS, Appium proxies command to a UIAutomation script running in Mac Instruments environment. Apple provides this application called ‘instruments’ which is used to do lot activities like profiling, controlling and building iOS apps  but it also has an automation component where we can write some commands in javascript which uses UIAutomation APIs to interact with the App UI. Appium utilizes these same libraries to automate iOS Apps.

Appium
In the above figure, we can see the architecture of the Appium in context to the iOS automation. If we talk about a command life-cycle, it goes like, Selenium webdriver picks a command form the code like (Element.click) and sends it in form of JSon via http request to the Appium server.  Appium server knows the automation context like the iOS and Android and sends this command to the Instruments command server which will wait for the Instruments command client (written in node.js) to pick it up and execute it in bootstrap.js with in the iOS instruments environment. Once the command is executed the command client sends back the message to the Appium server which logs everything related to the command in its console. This cycle keeps going till the time all the commands gets executed.

How Appium works in Android:

The situation is almost similar in case of Android where Appium proxies commands to a UIAutomator test case running on the device. UIAutomator is Android’s native UI automation framework which supports running junit test cases directly in to the device from the command line.It uses java as a programming language but Appium will make it run from any of the WebDriver supported languages.

Appium

In the above diagram we can see, here we have Bootstrap.jar in place of bootstrap.js which represents out test case when compiled in java. As soon as it gets launched it spawns a TCP server. Here the TCP server resides inside the device and client is in the Appium process which is just opposite to the way it is in iOS.

Appium’s Pros and Cons:

Pros:

  • The beauty of Appium is that, all the complexities are under the hood of Appium server and for an automation developer the programming language and the whole experience would remain same irrespective of the platform he is automating (iOS or Android).
  • The other benefits of Appium is that it opens the door to cross-platform mobile testing which means the same test would work on multiple platforms.
  • Unlike other tools Appium doesn’t require you to include some extra agents in your app to make it automation friendly. It believes in the philosophy of testing the same app which we are going to submit in the app store.
  • It is developed and supported by Sauce Labs and it is getting picked really fast with in the WebDriver community for mobile automation.
  • It can automate Web, Hybrid and Native mobile applications.

Cons:

  • Scaling up is an important consideration with Continuous Integration and Appium comes across as a great tool to fulfill this expectation. The reason for this is a technical limitation, in iOS we can only run one instance on Instruments per Mac OS so we can only run our iOS scripts on one device per mac machine. So if we want to run our tests on multiple iOS devices at the same time then we would need to arrange the same number of Mac machines, which would be costly affair. But this limitation can be resolved if we execute our scripts in Sauce Lab’s mobile cloud which at present supports running scripts on multiple iOS simulators at the same time.
  • Appium uses UIAutomator for Android automation which only supports Android SDK Platform, API 16 or higher so to support the older APIs they have used another open source library called Selendroid. So I would not say it as a limitation but it is definitely an overhead on the configuration side.

To Configure Appium on Mac

Following configurations are required to run Appium on Mac:

  • First we need to download the Appium app for Mac from this link. Once downloaded you need to move this app in to your applications folder and then you can launch it from your Mac Launchpad.
  • As Appium uses node.js internally so we would also need to install node on the mac machine, which can be downloaded from http://nodejs.org/ , it will download a node-v0.10.xx.pkg file which you need to install.
  • We also need to make sure we are using Mac OSX 10.7+
  • XCode 4.5 or higher version along with iPhone simulator SDK and Command Line Tools should be installed on the mac machine.

 

Amit Rawat

Amit Rawat

Senior Quality Assurance Lead

Amit Rawat is a Senior Quality Assurance Lead at 3Pillar Global. He brings with him rich experience in automation web, desktop and mobile based applications. He has expertise on various automation tools and technologies and has been deeply involved in designing Automation solutions for Telecom, Insurance, Banking and Consumer based mobile applications. In his own words, he has “always been passionate about learning new technologies with prime area of interest in the field of Mobile automation.” Prior to joining 3Pillar Global, he has worked for various product and service based companies including Oracle, Infosys, CSC and Markit.

60 Responses to “Appium: A Cross-browser Mobile Automation Tool”
  1. Nitika on

    hI aMIT,

    Can u please help me with desired capabilities for executing tests on real devices when i have .ipa file

    Reply
  2. Nagaraju on

    Hi Amit,

    Nice Information. Please provide your communication details.
    I Have few questions around UI Automation, will discuss those.

    Thanks,
    Nagaraju

    Reply
  3. Pritam Maske. on

    Really cool explanation….

    Reply
  4. salman on

    hi,

    i am using appium to automate native app for ios but for my next project i may require to use appium for web app in mobile browser. so is it reliable enough to create tests for mobile web app using appium? and what hurdles i can encounter which appium can not solve as of now?

    u can reply me on my email too.

    Reply
    • Amit Rawat on

      Hi Salman,

      It is more easy to automate web apps then automating a native app on iOS. For web apps you can simply utilize your existing selenium scripts. The only hurdle you will face is related to UI Interactions like tap, swipe etc so for that you can use javascript/jquery code to click.

      Reply
  5. Amit Chauhan on

    Hey Amit, Thanks for the Blog . Its quite helpful to get basic idea about appium.
    It would be great if you could share some blog/tutorial to learn appium. So that i can start writing from basic scripts.

    Thanks in Advance.

    Regards
    Amit Chauhan

    Reply
  6. Eldad on

    Hi,

    Is it possible to lunch several emulators in one instance ?

    Thanks

    Reply
    • Amit Rawat on

      Hi Eldad,

      In case of Android we can run as many emulators as we want depending upon the machine configurations. On a windows machine having 8gb ram, I have successfully launched three emulators.

      In case of iOS due to the limitation of Apple we can run only one instance of the simulator per Mac machine.

      Reply
  7. Kiran on

    Hi Amit,

    Provided tech notes on Appium Architecture is greatly helpful in understanding architecture behind Appium.

    Thanks for sharing this information as I am in initial stage to bring this into my organization for Mobile Native Apps automation using Open source solution.

    It has cleared all my doubts about Appium Architecture and its usage.

    Regards,
    Kiran Edupugnti

    Reply
  8. Ashish on

    hi Amit,

    I have shared a chunk of code with u. I am stuck. Please have a look and help.

    Thanks,
    Ashish Bajpai

    Reply
  9. Pradeep on

    Hi ,
    Thanks for a nice compilation . If we need to test with Multiple Mobile Devices then do we need to procure those devices or the tool will take care of them ?

    Regards,
    Pradeep

    Reply
    • Amit Rawat on

      Tool can take care of Simulators and Emulators as they are part of SDK. But if you want to run your tests on real devices then you have to procure them. There are few cloud based vendors which can help you on this are: SauceLabs, Tesdroid, TestObject, AWS Device Farm, Browserstack etc.

      Reply
  10. Ritu Tanwar on

    Please help me in setting up the framework

    Reply
  11. arjun m on

    Hi Amith,

    Please send how to use this app.

    Reply
  12. Jalpesh on

    Hi Team,

    We want to start appium server through Selenium script.
    Please suggest.

    Regards,
    Jalpesh Shelar

    Reply
  13. Naresh on

    Hi Amit,
    Thanks for the information shared. I have one more doubt like
    1. Does Appium supports API function calls written in the script?
    2. Does Appium execute JavaScript code or Objective-C code?

    Reply
    • Amit Rawat on

      Appium’s implementation is slightly different from Selenium so it does not have direct access to the native code written in ObjectiveC in case of iOS and Java in case of Android. It leverages the UI automation libraries given by these platforms to access the UI elements and do operations on them. So we cannot not directly call the ObjectiveC code from your Appium code.

      In case of iOS it used Apple’s UIAutomation framework which internally uses java script so we can say that your appium code is converted in to java script code and then it is executed on your iOS device.

      Reply
  14. chari on

    hi amit,

    i had configured Appium and android sdk…
    i had written a simple code to launch browser and login to the application…
    it is working fine result is pass(executing on chrome by default)…

    here is my question

    how to run the same code on android 4.3 device in firefox browser and android browser

    here is my code

    File app = new File(“Computer\\GT GRAND2\\Phone\\Android\\data\\com.sec.android.app.sbrowser.apk”);
    DesiredCapabilities capabilities = new DesiredCapabilities();
    capabilities.setCapability(CapabilityType.BROWSER_NAME,”browser”);
    capabilities.setCapability(“deviceName”,”GT GRAND2″);
    capabilities.setCapability(“platformVersion”,”4.3″);
    capabilities.setCapability(“platformName”,””);
    capabilities.setCapability(“app”,app.getAbsolutePath());
    capabilities.setCapability(“appPackage”, “com.sec.android.app.launcher”);
    capabilities.setCapability(“appActivity”, “com.sec.android.app.launcher.Internet.MainActivity”);
    driver = new RemoteWebDriver(new URL(“http://127.0.0.1:4723/wd/hub”), capabilities);
    /*passing the URL and Open The Browser*/
    driver.get(“https://www.google.co.in”);

    so please let me know …

    thanks in advance

    Reply
  15. Bharat Kashyap on

    Hi Amit,

    Thank you for the useful information.
    In one of my project in order to do mobile automation,I am using Appium + Selenium + C#. I am done with configuration and writing basic test cases. As the test cases becoming complex i am finding difficulty to get the function provided by Appium + Selenium + C# to write the test case. Can you please provide me the list of available function with description in Appium + Selenium + C#. I have searched lots of websites but could not find the details.

    Thanks

    Reply
  16. Seni on

    Hello Amit,

    Thanks for this blog. Can you shed more light please, I have requirement to test my company website on mobile devices (Android and iOS) – which do you recommend to test on simulator or on real devices and is it possible to configure this test with a build server like teamcity for scheduled runned test.

    Thank in anticipation.

    Seni.

    Reply
    • Anshu Khandelwal on

      Hi Seni,
      In Case of Android go with real devices and in case of iOS choose simulator. I am using Appium with selenium on live site and found more stability on Android real device as compare to iOS real device.
      Regarding scheduled build not sure about team city but yes you can integrate it with Jenkins which is the the best tool I have ever seen till now for integration and run,

      Thanks
      Anshu Khandelwal

      Reply
  17. Manish Birthariya on

    Hi Amit,

    Its very knowledgable blog, and you explain it in very detailed as well.

    I am also working on Appiun since last few months and delivered some successful projects as well.
    But now I am facing some issues, as trying to Automate Android Hybrid app, I think this is not the right place to explain all details, It would be very kind for me if you share you email id so that i can inbox you the more details.

    Thanks You!
    Manish B

    Reply
  18. Ankit Khandelwal on

    I just have a basic question, can we use the same script created in Java for iOS and Android both ??? or some modification is required for that too.

    Assuming :
    object locator is same for iOS and Android both .

    Reply
  19. ravi on

    can u tell me the way to set up the grid for ios devices.any alternate way for ios grid.i know appium does not support grid

    Reply
  20. Ravi on

    Hi Amith
    Is there any way to set up a grid for ios devices.i know appium does not support gridlet me know if any alternate way

    Reply
  21. Ravi on

    Hi Amith
    Is there any alternate way to set up grid for ios devices by appium

    Reply
  22. Albert on

    Using appium I’m launching a safari launch app which opens safari browser (on a real device).. I’m trying to take a a screenshot… And what happens that when I’m using WebDriver driver1 = new Augmenter().augment(driver); to capture the screenshot, it doesn’t capture the entire page I only can capture what I see … any work around …

    Reply
    • Amit Rawat on

      By default Appium doesn’t support this so we need to find a way to scroll the page and keep taking the screenshots of the each page scroll and then in the end we have to stitch all the images together. I have done this and you can see the complete code here and feel free to use it and provide me the feedback if it doesn’t work for you.

      https://gist.github.com/sahajamit/b680e02fc8963a25d130

      Reply
  23. Ganesh on

    Hi,

    I am trying automation using Appium on iPhone device using java- selenium,.

    1. We have successfully spy the objects of the app and developed the scripts using Java – selenium.
    2. While running it, it throws an error “App elements not visible” in appium console, when we attempt to tap on the elements on device (manually), it doesn’t respond any. This happens every time we ran our script.

    We have successfully done for android for the same app.

    Could you suggest us what might went wrong? please share your thoughts.

    Reply
    • Amit Rawat on

      This is really strange. This usually happens when your app is having too many UI elements on the screen and they gets loaded at the same time. So when appium tries to fetch the UI element tree then it finds it difficult the UI tree is too heavy to parse. Please try changing the locator of your UI element, make sure you are using accessibility id.

      Reply
  24. jaiveer on

    Hi Amit,
    The iOS application which i wish to automate is in Flex and the build is made from Flash builder. Is it possible to use Appium in this case?

    Reply
  25. Kallem Sandeep on

    Hello Amith,

    Can you please provide me the step by step procedure for setting up Appium in android studio for Ubuntu.

    Any suggestions would be appreciated.

    Reply
    • Amit Rawat on

      Appium is not a tool which is tightly coupled with Android development kit so it is not necessary that you have to use Android Studio for automation using Appium. Appium supports multiple languages including java so you can select the Java IDE of your choice Eclipse/IntelliJ and write your own code the way you want. Here you can find some good examples on how to start with Android automation using Appium. https://github.com/appium/sample-code/tree/master/sample-code/examples/java/junit/src/test/java/com/saucelabs/appium

      Reply
      • dhivya on

        Hi,I installed appium in my mac and running test on emulator inside mac.

        I’m pretty much confused about where exactly is my appium server installed?
        If I have my appium tests(using webdriver appium client) present in windows and appium GUI(called as appium server) installed inside mac and have my emulator present in mac,will tests run?will this setup work?

        Reply
  26. dhivya on

    Hi,I installed appium in my mac and running test on emulator inside mac.

    I’m pretty much confused about where exactly is my appium server installed?
    If I have my appium tests(using webdriver appium client) present in windows and appium GUI(called as appium server) installed inside mac and have my emulator present in mac,will tests run?will this setup work?

    Reply
    • Amit Rawat on

      Appium works like Selenium RemoteWebDriver. You can run the appium server on your Mac and it will listen to your commands from appium client (that could be on a separate windows machine also) via htttp based Mobile JSON Protocol.

      If you using command line interface of Appium server then it gets installed at this location in your mac: /usr/local/lib/node_modules/appium

      I hope I have answered all your questions.

      Reply
  27. Bhupendra on

    Hii Amit i am new in Testing. and i am learning Appium pls help me m getting stuck most of the time..

    Reply
  28. Amit Rawat on

    Hi All,

    I will not be available on my official email id from next week. So for all your queries you can reach me at sahajamit@gmail.com

    Reply
  29. Nikki on

    I would like write test cases using Appium in Android Studio. Could you please provide steps to set up Android Studio to support Appium. A sample test case would be helpful.

    Thanks,
    Nikki

    Reply
  30. Prashant on

    Hi,

    Can you provide any idea on whether Appium can automate default iOS apps ( settings,message apps)

    Reply
  31. Rakesh on

    Hi Amit, can android app element (let’s say for username field) be located by xpath using class and index attribute as:
    dr.findElement(By.xpath(“//android.view.View[@index=’0′]”)).sendKeys(“rakes”);
    Actually, my code script could not succeed to locate element and got error.
    So what others possible solutions could be there so that I can locate the particular elements?

    Reply
  32. Piyush on

    Hi,

    I have downloaded appium 1.4.16 from https://github.com/appium/appium/releases this link. and run this command on terminal “./appium.js –app /Users/ART/Documents/testTrial.app -U 41b1798401b6cd3346d045620771579b93f9b6b4 -a 0.0.0.0 -p 4723” but it was not working it was showing some error. so please provide me running appium.

    Reply
  33. Megha on

    Hi Amit,

    I would like to AUTOMATE our application using Java . Do you have any frameworks designed for appium using Java? Can you please share the details

    Thanks in advance,
    Megha

    Reply
  34. Suraj on

    Hi Amit,

    I came across your blog and it was very helpful. Thankyou for sharing your knowledge.

    I had some doubts regarding automation of cross platform application built in ionic2.

    I am facing a lot of issues while trying to identify the elements. When I am trying to identify ionic specific tags using xpath I am not able to..

    I used xpath as //ion-input[@class=’abcd’] but appium is not able to identify this. It says “Object reference not set to an instance of an object” error.

    While this xpath is working for ios hybrid app, but the same is not working for android hybrid app.

    I am struggling with this from very long time with no help from online forums.

    Please let me know if you have solution for this. Thankyou.

    I dont have any website hence wrote google.

    Best Regards,
    Suraj Gupta

    Reply
  35. Suraj on

    Hi Amit,

    I came across your blog and it was very helpful. Thankyou for sharing your knowledge.

    I had some doubts regarding automation of cross platform application built in ionic2.

    I am facing hell lot of issues while trying to identify the elements. When I am trying to identify ionic specific tags using xpath I am not able to..

    I used xpath as //ion-input[@class=’abcd’] but appium is not able to identify this. It says “Object reference not set to an instance of an object” error.

    While this xpath is working for ios hybrid app, but the same is not working for android hybrid app.

    I am struggling with this from very long time with no help from online forums.

    Please let me know if you have solution for this. Thankyou.

    Best Regards,
    Suraj Gupta

    Reply
  36. Chirag on

    Hi Amit,

    Currently I perform manual testing for native and hybrid mobile application. I have recently tried my hands on Selenium Webdriver for web projects with Data and Keydriven framework.

    By going through the thread related to appium it has made me eager to start soon with Appium but before that can you please address my following concerns:
    1. Please refer the source by which it clears the most basic concepts of appium ranging from Installation to basic test scripts.
    2. I am using windows laptop and does not have macbook or mac machine so in this case how can i study or prepare the test script for iOS.

    Regards,
    Chirag

    Reply
  37. Akansh on

    Hi

    can we find downloaded excel file in android device and validate it content using appium. ??

    Regards
    Akansh Garg

    Reply
  38. Dev on

    Hi Amit, This post if very informative.
    I have few questions and request to help me `as I am new to Appium.

    1. I am trying to run the appium scripts on android device (on web chrome browser) . It does not launch the browser on my android device. Below is the desired capabilities used. Is there any thing I am missing in the code ? I am NOT using any grid. Below is the snippet of code used.

    DesiredCapabilities capabilities = new DesiredCapabilities();
    capabilities.setCapability(MobileCapabilityType.BROWSER_NAME, “Chrome”);
    capabilities.setCapability(MobileCapabilityType.PLATFORM_NAME,”Android”);
    capabilities.setCapability(MobileCapabilityType.DEVICE_NAME,”SAMSUNG-SGH-1337″);
    capabilities.setCapability(MobileCapabilityType.PLATFORM_VERSION, “4.2.2”);
    driver = (WebDriver) new AndroidDriver(new URL(“http://127.0.0.1:4723/wd/hub”), capabilities);
    driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
    driver.manage().timeouts().pageLoadTimeout(60, TimeUnit.SECONDS);
    driver.get(“http://google.com”);

    Thanks,
    kb
    kbmail09@rediffmail.com

    Reply
Leave a Reply

Related Posts

Innovation Wars, with Scott Bales Scott Bales joins us on this episode of The Innovation Engine to dive into the concept of "innovation wars." Among the topics we'll discuss are what c...
Heather Combs to Moderate Panel at IES Conference 3Pillar's Heather Combs will moderate a panel at the IES Women in Sales Q2 Straight Talk Panel Discussion on April 13th in Vienna, Virginia. The panel...
Jessica Hall and Paul Axente Present at UX Talks On March 14, 2017, 3Pillar's Jessica Hall and Paul Axente presented at the UX Talks event in Cluj-Napoca, Romania. UX Talks centered on how UX shapes ...
Automation Testing: Excel to SQL Query Creation Objective We're looking to automate regression testing data preparation by populating data for different scenarios from Excel spreadsheets to a datab...
Take 3, Scene 21: Building a Serverless Architecture Derek Tiffany and Huagen Peng join us for this episode of Take 3 to talk us through the process of building a serverless architecture, and why this ca...

Free product development tips delivered right to your inbox