Showing posts with label Android. Show all posts
Showing posts with label Android. Show all posts

Wednesday, July 18, 2012

Android automation tools/frameworks


As we all know the market of android based devices is increasing day by day. Due to this lot of companies are developing android based applications. These applications can be categorized as following:
  • Native apps - Apps that are developed using native android classes and runs on the device android OS.
  • Webapps - These apps are actually web-applications  that are customized to work with Android based mobile devices.
  • Hybrid apps - These apps are the mix of Native and Web based development. Such kinds of apps have some Native coding to interact with device hardware resources like camera,recorder, speaker etc. along with some web based components to directly serve the pages from a web-application itself.
With such a variety of apps in the market the QA will have a difficult task in hand, that is to automate such applications. There are a lot of tools and frameworks available in the market that can help you with automating the android apps. In this blog I will list a few of them and basic info about it. Following are some of the opensource apps available in the market:
  • Robotium - Android automation framework built over Android instrumentation testing provided by the Android itself. This is currently one of the major frameworks available that can be used a base for your android app automation. More info at: http://code.google.com/p/robotium/
  • NativeDriver - Extension of Selenium webdriver for Native android automation.This currently discontinued and no further support or development is being done on it. More info at: http://code.google.com/p/nativedriver/
  • Bot-bot - An Opensource android automation project built over Robotium and NativeDriver frameworks. Comes with recording features to record user actions and export them as test case. It currently supports recording user actions of native application elements and new work is going on to support recording on Web-based/Hybrid apps. More info at: http://imaginea.github.com/bot-bot/
  • MonkeyTalk -  Monkey talk is based on Android instrumentation testing provided by android. It have recorder which can be used as a eclipse plugin. The tool seems to be unstable and there is not much changes/ bug fixes that is seen.
  • Calabash - Calabash is another android/ios automation tool available in the market which uses cucumber as its base. More info is available at: https://github.com/calabash/calabash-android
Will keep on updating the list whenever I find something new.

Wednesday, February 8, 2012

Native android application automation using bot-bot

Its been long time that I had written a blog here. I was busy with writing an android automation tool for native android application testing, named as "bot-bot". Please take a look at it and let us know your comments. This is work-in-progress and there are lot-of features that still have to implement.

Following are some of the links giving information on bot-bot:
Webpage:
http://imaginea.github.com/bot-bot/

Github page:
https://github.com/Imaginea/bot-bot

Most of the things are covered in the webpage or in Github.
In case of issues you can contact me or send a mail.

Friday, September 23, 2011

Automating a Native android app using Selenium and NativeDriver

As there are more and more development happening on the android front, automation of the developed applications has also become a necessity. Android within its API supports a testing framework which can be used for testing applications, but writing and developing cases using that API is not easy. We may need a framework that makes it easy to write and develop test cases for our applications.
One of such framework is "NativeDriver". It is built over the Selenium webdriver automation framework.
As you must be knowing that selenium is vastly used open-source functional automation tool. 
In this write-up I will tell you on how to automate an android application using NativeDriver
Following things are required before starting:
  • Android SDK 2.2 or later - download
  • Eclipse version 3.5 or later (Eclipse IDE for Java Developers recommended) - download
  • Android Development Toolkit (ADT) plug-in - Installing ADT
  • Ant - download
  • JDK 1.6 or later - download
Building the NativeDriver libraries:
  • Checkout the NativeDriver code:
  • svn checkout https://nativedriver.googlecode.com/svn/trunk nativedriver --username {Google account e-mail address}
  • Build the NativeDriver code:
  • $ cd nativedriver/android
    $ ant

The libraries are built and stored in the nativedriver/android/build directory:

  • server-standalone.jar - this should be linked to your Android application, and runs on the Android device (or emulator). This is the NativeDriver server, and listens for requests to automate the application, such as “start an activity” or “click a UI element”
  • client-standalone.jar - this should be linked to the test, which is the NativeDriver client. It implements a WebDriver API which communicates with the server.

Adding the NativeDriver jar to your application



  • Import your android application code into the eclipse by using the File -> Import functionality of eclipse.
  • Add the server-standalone.jar to the build-path of your android application by Right clicking on the Android application project -> Configure build path -> Add jars or Add external jars (browse to the server-standalone.jar file, select and add it).
  • To the application AndroidMainfest.xml file, add the following to the element.

 <instrumentation android:targetPackage="{app_package_name}"
   android:name="com.google.android.testing.nativedriver.server.ServerInstrumentation" />
   android:name="android.permission.INTERNET" />
   android:name="android.permission.WAKE_LOCK" />
   android:name="android.permission.DISABLE_KEYGUARD" />
           Here {app_package_name} needs to be replaced with the name of the package as specified in the mainfest element's package attribute.
  • Build the application and install it on the device.
  • Now go to the commandline and start the instrumentation using the following line:
adb shell am instrument {app_package_name}/com.google.android.testing.nativedriver.server.ServerInstrumentation
Here again the {app_package_name} needs to be replaced with the name of the package as specified in the mainfest element's package attribute.
  • Enable port forwarding by using the following command:
adb forward tcp:54129 tcp:54129

Writing your Test Cases
For writing your test cases you just have to create a new Java project and start writing code for it. I will explain this using a code example. The following code is done to automate an opensource K9 mail application on android:


Important Notes:-

  • As there is no recording feature available, we need to write the code manually for automating our scenarios. 
  • For identifying the element id to interact on the UI, you can get the ID's of the elements from the R.java file generated inside your android application code.
  • Also as we are writing our cases in Java code we can use our own test framework and generate html reports for out automation execution.


Note: Most of the material in this blog has been taken from the original site of the NativeDriver. The credit for such material goes to the original author.
Following is the link to it. http://code.google.com/p/nativedriver

Wednesday, August 17, 2011

Native android app automation – Nativedriver vs Robonium

Nowadays android is the latest thing in the market and many of the companies are working on android app development. With development comes the requirement to test an application too. As we all tester know that automation is one of the important part of testing, and is mainly used to reduce the time taken to execute the testcases. This gives time to testers to concentrate more on exploratory testing. Recently I was going through some group, and found out about some open-source frameworks that makes it possible to automate an Android native application. I went through two of such frameworks and will write about what I felt about them. The two frameworks I am going to talk about is Nativedriver and Robonium. 

Nativerdriver- Is an opensource framework written over Selenium-2.0 Webdriver implementation. As we all know that selenium is a great functional automation tool for web-applications and gives you a cross-browser and cross-platform supports. The support for testing native application has enhanced the value of selenium. Nativedriver can be used when you are actually working along with the development team and has access to the source code of the andorid application that needs to be tested. 

Robonium – Is also a great tool and is written by extending the Internal Android testing framework. This framwork supports a lot of functions which can be used to auotmate your application test. The main advantage of this framework is that , you can automate any application using this without actully having the source code of the app.

Advantages of Nativedriver: 
  • Built over the selenium webdriver hence can be easliy used by existing selenium users.
  • Test are run as a normal Java unit test. And hence other frameworks can also be used for test-case execution or reporting.
  • Ant or maven can also be used for execution of cases.
  • Fast execution and reporting of testing results
Disadvantages of Nativedriver:
  • Need access to the source code of the application that needs to be tested.
  • Sometime difficult to find element as support for finding elements by index is not available

Advantages of Robonium: 
  • Don't require the source code of the application for testing.
  • Elements are easy to identify and work on.
  • Tests are simple to write.
  • Setup is simple.
Disadvantages of Robonium
  • Can only be executed suing eclipse.
  • Slow execution.
  • Typing a normal text is not supported at this point.