Home » Robotium » Page 2

Category: Robotium

Latest updates from robotium

Since my last robotium blog posts, robotium was improved in several areas. Since version 4.0 robotium supports webviews and with version 4.2 robotium provide a full support for hybrid apps.
You can use methods like:

  • typeTextInWebElement(By by, String text)
  • waitForWebElement(By by)
  • clickOnWebElement(WebElement webElement)
  • clearTextInWebElement(By by)
  • getWebElement(By by, int index)

Also a great improvement is the robotium remote control (RC). With RC you are able to execute your test cases from the Java Virtual Machine (JVM). This enables robotium to work with several JVM frameworks like JUnit 4. To use the RC in your project have a look at the installation and development instructions.
RC can be downloaded from here.

Have fun!

Building Test Suites for Robotium

If you have implemented many automated tests with Robotium, you will notice that Robotium is not the fastest tool when it comes to test execution time! Especially in big projects with more than 100 automated Robotium tests the execution time is really long (>1h). For nightly regression testing this is not a problem, but If you want to know if a simple commit from a developer break something, executing the whole test suite is not very efficient. To get a much faster impression of the quality of the last commits, you can build for example a smoke test suite. This suite covers the basic functionality like login, clicking on important entries but not all edge cases, like a full regression test suite will do. Read more

OutOfMemory Exception with Robotium – Update IV

If you are using Robotium for test automation your Android app and you have many test cases that must be executed, you may run into an OutOfMemory Exceptions after a certain time of test execution.
I have this problem with my test suite. The full test suite consists of around 110 test cases. Besides the full test suite I created a smoke test suite that contains about 40 test cases.
On both suites I get the OutOfMemory Exception no matter which device I use for testing. First I thought, I made some mistakes in my tearDown() method or on the general Robotium setup. But this is not the case. If you call the finishOpenedActivities() method in your tearDown() method, not used activities should be removed and the memory of the device should be freed as well.
I searched on the internet and found the reason for this problem on the official Robotium page. There is currently a bug in the finishOpenedActivities() method.

See the commment from Renas Reda:

“The issue here is that we can not break backward compatibility (getOpenedActivities()). Also this is not only a blackbox test framework, people may be interested in getting a hold of the activities that have been opened. Another reason for the Activity references to be kept is due to being able to finish them at the end. That is needed as having a old Activity still open and in focus will lead to complications with the next test case. Many times activities are not cleaned properly and therfore manually calling finish is a must.
Using weak references could work. I will send you a version where Robotium uses weak references to the Activities instead. Please let me know if it works better for you.”

For more information please check the Issue 249 and watch it ;). It looks likes the problem is already solved and I hope the new Robotium release will available in the next days/ weeks!

Drop me a comment, if you have/had similar problems with your Android testing setup using Robotium.

Update 12. June 2012:
Since 11. June 2012 a new Robotium version 3.3 is released. This new version of Robotium fixed the Issue 249, the OutOfMemory Exception in big projects. Besides that some brand new methods are available for testing.

  • takeScreenshot()
  • clickOnActionBarItem(int resourceId)
  • getCurrentImageViews(View parent)

If you want to use the takeScreenshot() method, the application under test need the following permission in the AndroidManifest.xml android.permission.WRITE_EXTERNAL_STORAGE.

Update II: 14.06.2012

Sadly, the OutOfMemory Exception is not yet fixed. The problem still exists. I am already talking to Renas Reda and try to help him fixing the problem. I will inform you when the bug is fixed!

Update III: 02.07.2012

The problem still exist in the current version of Robotium 3.3. I mailed several times with Renas Reda and he doesn’t know why this is happening. For now, as a workaroung I call the garbage collector manually in my tearDown method. My tearDown looks like this:

public void tearDown() throws Exception {

try {
solo = null;

} catch (Throwable e) {


At least my full testsuite is now running again, without any Out Of Memory Exceptions.

Update IV: 07. August 2012

A new Robotium version 3.4 is out.
http://code.google.com/p/robotium/. In this release the out of memory exception is fixed! Additionally the Robotium team included some really nice new methods like:

scrollToTop(), scrollToBottom(), scrollListToTop(int index), scrollListToBottom(int index), waitForFragmentById(int id), waitForFragmentByTag(string tag), waitForLogMessage(string logMessage), clickOnActionBarHomeButton(), takeScreenShot(string filename)

Have fun!

Robotium 3.0 is out there!

Since November 16th the latest version of Robotium 3.0 is released. This new version of Robotium provides several new and improved methods to test your Android app. As Renas Reda in the jayway blog says: “Robotium is now faster, lighter and more stable then ever!” I hope that is true because the previous versions of Robotium were really slow in the execution, even on real devices. So let’s see what’s new!

The following two methods are new to wait for views:
Read more

How to setup a test environment for Android using Robotium

This post should show how easy it is, to setup an robotium test environment for Android Apps using the Eclipse IDE. First of all you have to download the latest Android SDK depending to your operating system from http://developer.android.com/sdk/index.html. After downloading the zip file you can unzip it to:

  • /opt for Linux system
  • /Applications for Mac OSx systems
  • c:Programs for Windows systems

AVD – Manager
Start the Android avd manager with the command ./tools/android. Read more