DevOps | Software Automation | Continuous Integration

Category: Mobile Automation

Appium: Introduction & Getting Appium Working for iOS App

Introduction

I came across Appium as an open source tool for mobile testing in the Google Testing Conference 2013. The details from the presentation can be found GTAC 2013 – Appium: Automation for mobile apps.
The previous open source mobile automation tool that I had experience with are quite restricted in terms of its whether for merely iOS like Frank or Android like Robotium.
Appium is a specialised testing tool for both native and hybrid iOS and Android apps, including web applications on mobile web browser.
In my coming posts, I am going to share with you my experience in spiking out the tool in both Mac and Windows environment.

Appium working in iOS

Install

  • Get a Mac. My colleague of mine has tried to set up a virtual machine to run XCode on Windows but don’t seem to have much luck.
  • Install node.js as it is needed to “fire up” Appium, otherwise you can download the Appium app
  • Download Appium as illustrated from the screen shot taken from the Appium website
You are able to find sample test code written in many different languages. The good thing about Appium is that it is not language dependent, so feel free to choose any language that you’re more familiar with. In my case, I’ve chose Ruby.

Run test for iOS App

  • Start Appium by typing appium & in the Appium folder
  • Start iPhone simulator by going to Xcode->Open Developer Tool->iOS Simulator. Under iOS Simulator->Hardware->Device, you can select the device type. Eg: iPad or iPhone

  • Ensure we set the path of app correct in sample-code/sample-code/examples/ruby/cucumber_ios/features/support
  • Go to the sample-code folder and run the Cucumber test

Mobile Automation For Android

If you have a native Android application, I would recommend you to use Robotium. Due to the fact that the project that I am working on is not, I have chosen Selenium.

Below are the details about the framework that I am using:

  • Follow the instructions as mentioned in http://code.google.com/p/selenium/wiki/AndroidDriver
  • The method that I chose is Android WebDriver using Android Test Framework
  • Therefore, the main thing you need is Android SDK, Eclipse, Android phone, and a USB cable
Below are the stuff that I have learnt in the process of setting up this framework:
  • Would be best to test on actual device instead of emulator because Android emulator is too slow and consumes a lot of computer resources
  • The test only works for Android version 4.0 or above

Mobile Automation For iPhone & iPad Using Selenium WebDriver

If your mobile application is not a native mobile application, you might need to use some language independent testing framework such as Selenium.

Below shows how to set up this framework:

          – Right click on the test folder you created
          – Go to Build Path -> Configure Build Path
          – Click on the Libraries tab and click on Add External JARs
          – Select the selenium-server-standalone.jar file
  • The code for my project can be found in https://github.com/ChuanChuanLaw
  • Run the iPhone web driver and run the test via clicking on the Run button in Eclipse
  • Select iPad emulator if you want to run tests in iPad

Open Source Mobile Test Automation Framework

The popular ones in the market are as below:

Frank

  • Developed by Thoughtworks
  • Can only be used on iOS applications
Robotium

 

  • Can only be used by Android applications
Sikuli
  • Easiest to use among all because no scripting is needed
  • It works based on screen capture
  • Need to have separate tests for iOS and Android applications because of the different UI
Selenium
  • Most flexible. Can be used on both iOS and Android applications
  • Hardest to set up among all

Frank – Mobile Automation Testing Framework

Frank is an open source mobile automated acceptance testing framework developed by ThoughtWorks. It uses Cucumber. Instead of driving browser, it drives iPhone or IPad simulators.


It can be downloaded via http://github.com/moredip/Frank. The official website for Frank is http://www.testingwithfrank.com/index.html.


The installation guide is comprehensive, apart from the following steps which need to taken care of:

  • Remember to do a gem update to enable everything to work properly. Otherwise  http://localhost:37265 will not be responding.
  • Set in the command line export e.g.: export APP_BUNDLE_PATH=/Users/chuan/Library/Developer/Xcode/DerivedData/TopSongs-firzpluxqrfpthdcoezcyirxkdgr/Build/Products/Debug-iphonesimulator/TopSongs copy.app

Advanced Selenium C#

  //Mouse over the Main Menu
  Actions builder = new Actions(driver);
  IWebElement menuBar = driver.FindElement(By.XPath(“//a[@id=’menuMyTeam’]”));
  builder.MoveToElement(menuBar).Perform();

  //Click on the sub menu
  var click = builder.MoveToElement(menuBar.FindElement(By.XPath(“//a[@id=‘Team_TalentNineBox’]/span”)));
  click.Click();
  click.Perform();

  //Drag and drop 
  Actions move = new Actions(driver);
  IWebElement empToMove = driver.FindElement(By.XPath(“//li[@id=’employee_308145′]”));
  IWebElement empTarget = driver.FindElement(By.XPath(“//li[@id=’employee_308144′]”));
  move.DragAndDrop(empToMove,empTarget).Perform();

© 2023 Chuan Chuan Law

Theme by Anders NorenUp ↑