Saturday, March 31, 2012

robotium button click not working solution

I also had this issue and i couldn't find a solution with robotium. Then i move to the android instrumentation provided with the SDK. What i have done is mentioned below. This worked without any issues for me. Here it is ..

First define a private variable for the button as a member variable
private Button msButton; 

 Then get the button instance with in the setup method.

mButton = (Button) solo.getCurrentActivity().findViewById(

Then call the button click with in the UI thread in the test method as mentioned below.

//Test button method

public void testButtonClick() {

//Get the current activity and request to run onUI thread       
        solo.getCurrentActivity().runOnUiThread(new Runnable() {

            public void run() {

//Request focus for the button

//Send the button click event

That's it .. Now you can test your button with other Robotium features.
Cheers !!!!!!!!

Install Sinhala fonts in ubuntu

This is so simple. just type the following command in terminal window.'

sudo apt-get install ttf-sinhala-lklug

That's it. Now you can see Sinhala fonts

Friday, March 30, 2012

Android testing with monkeyrunner - a monkeyrunner tutorial part II

I hope that now you have an idea about what is monkeyrunner and what you can do with it. Let's start doing them.

How to install?
Oh .. oo .. you don't need to install it separately. It comes with Android SDK package. Inside your android-sdk-windows or linux package, inside tools directory, you can find this tool monkeyrunner.

How to run monkeyrunner?
If you want to run monkeyrunner from anywhere within the command line, you need to add the path of the monkeyrunner directory(\tools ) to your system PATH variable. changing path variable can be seen in this simple post .

once you have the PATH variable set, you are ready to go.... But wait .. you should have something to run with monkeyrunner. It is none other than a python script.
Let's write a simple python script to test your application.

How to write your first script?
monkeyrunner API provides 3 modules which are located in namespace. You will be using these modules to run your tests with monkeyrunner tool.

  • MonkeyRunner: A class of utility methods for monkeyrunner programs. This class provides a method for connecting monkeyrunner to a device or emulator. It also provides methods for creating UIs for a monkeyrunner program and for displaying the built-in help.
  • MonkeyDevice: Represents a device or emulator. This class provides methods for installing and uninstalling packages, starting an Activity, and sending keyboard or touch events to an application. You also use this class to run test packages.
  • MonkeyImage: Represents a screen capture image. This class provides methods for capturing screens, converting bitmap images to various formats, comparing two MonkeyImage objects, and writing an image to a file.
If you can't understand what these modules are for and what you are going to do with them, It's OK. you will know about them as you read the next section.

  1. First you need to import the modules which you are using in this script
from import MonkeyRunner, MonkeyDevice

  1. Then you have to connect to the device which you are running your test

device = MonkeyRunner.waitForConnection()

  1. Then you need to install the application package to the device

(Here the folder name is given as a relative path. Yamba folder should be located in the same directory in which you are currently in. You can give the absolute path as well.
For Windows users,
you can give the path as ('C:\\Program Files\\Yamba\\bin\\Yamba.apk') as your absolute path. 

  1. set the package and the activity to be started

package = ''
activity = '.MainActivity'
runComponent = package + '/' + activity

  1. Run the activity on the device


  1. Wait for 2 seconds before sending the next command


  1. Send a menu button press event'KEYCODE_MENU', MonkeyDevice.DOWN_AND_UP)

  1. Wait for 2 seconds before sending the next command


  1. Send a touch event to a button located at bottom center of an HVGA device

device.touch(200, 390, 'DOWN_AND_UP')

  1. Wait for 2 seconds before sending the next command


  1. Take a screenshot of the resulting window

result = device.takeSnapshot()

  1. Write the screenshot to a file


Name this script as and save it on your current directory. (You can save it anywhere...)
Now it looks like this

# Imports the monkeyrunner modules used by this program
from import MonkeyRunner, MonkeyDevice
# Connects to the current device, returning a MonkeyDevice object
device = MonkeyRunner.waitForConnection()
# Installs the Android package. Notice that this method returns a boolean, so
# you can test to see if the installation worked.
# sets a variable with the package's internal name
package = ''
# sets a variable with the name of an Activity in the package
activity = '.MainActivity'
# sets the name of the component to start
runComponent = package + '/' + activity
# Runs the component
# Wait for few seconds
# Presses the Menu button'KEYCODE_MENU', MonkeyDevice.DOWN_AND_UP)
# Wait for few seconds
#Touch the new status button
device.touch(200, 390, 'DOWN_AND_UP')
# Wait for few seconds
# Takes a screenshot
result = device.takeSnapshot()
# Wait for few seconds
# Writes the screenshot to a file

Then on the command line or in a terminal window type this command

monkeyrunner -v ALL

(wait … what is this -v ALL thing …

-v is for verbose mode
ALL is for printing all the messages from monkeyrunner tool )

now you can see that the test is running on your device(s) or emulator(s).

cheers !!!!!!!!!

Android testing with monkeyrunner - a monkeyrunner tutorial - Part I

This is what you have been waiting for .. A simple tutorial about all the things you need to know about monkeyrunner testing tool provided by android SDK.

What is monkeyrunner?
It is a tool which provides an API for writing programs that control an android device from outside of android code.

What you can do with monkeyrunner?
You can write python programs to test the applications on one or more devices and/or emulators. You can do following things and more with monkeyrunner.
  • Installs an application or test package
  • Runs an application
  • Send keystrokes or touch events to it
  • Take screen shots of the user interface
  • Store screen shots on your workstation
You can do all those things from your PC or laptop remotely.

Why monkeyrunner?
This is primarily designed to test applications and devices at the functional/framework level and for running unit/functional test suites.

What is unique about monkeyrunner?
Unique features of monkeyrunner includes
  • Multiple device control
  • Functional testing with screen capture
  • Regression testing - run an application against a particular result
  • Extensible automation
What is under the hood?
It uses Jython, an implementation of python that uses the Java programming language.

What is more on this tutorial?
 I will discuss more about running and configuring monkeyrunner in my next tutorial ...

cheers !!!!!!!!!!!

Wednesday, March 21, 2012

How to change $PATH variable in ubuntu

PATH variable in Windows and Linux will help the operating system to find the commands we are executing in the command line within the system.

In other words, if you want to run any command within any folder in your system, system should be able to find that command file. PATH variable contains the folders in which that particular command you have typed, can be stored in the system.

 if you want your custom commands or tools to be run from anywhere in the command line, you need to add the folder which contains that command or tool in to the PATH variable.

in Windows you can change the PATH variable in the Enviornment variables section under system variables. (You can get the System properties window by clicking WIN + Pause keys. )

in ubuntu you change the path within the command line by typing the following command.

export PATH=/folder/contains/the/tool:$PATH

This will add the folder "/folder/contains/the/tool" to the system PATH variable. Then you can run your command or tool from anywhere in the system.

cheers !!!!!!!!!!!!!!!!

Saturday, March 17, 2012

HP Laptop not loading BIOS screen stuck in HP logo black screen

It took more 10 hours to fix this issue for me. I have been searching for a solution in google and rather than finding a proper solution i found solutions which were threatning. Finally I got a solution for this issue.


I have a HP pavilion dv5 laptop which i was using for more than 3 years. It was factory installed Windows Vista laptop and i was working fine with that for more than 3 years. Then i got an idea to update it to Windows7. I have been able to update it without any issue. But when i was using Windows7 for few hours, I found that my battery is shown as broken ( X mark in the battery indicator). Then tried to update the driver for battery but it didn't work for me. Then i tried to restore the Vista.But it gave me an error saying that some system registry settings are wrong or something related to that. After that, when started my laptop with power button, It stuck on the HP logo screen with a text field in the left bottom corner which mentioning press ESC for Startup options. something like that. I was almost stunned. I have tried several things mentioned in blogs.


I have downloaded the BIOS setup file from HP support site. Which was an exe file and I have extracted the content in that file using 7Zip. In the extracted folder, I found two files 3602F21.FD and 3603F21.FD. (These are for my pavilion dv5 1125em).
Then i copy those 2 files to my USB stick and then copied another 4 copies of those files. Now there are 6 files in USB. then renamed them  to 3602.BIN, 3603.BIN, 3602.WPH, 3603.WPH, 3602F21.BIN, 3603F21.BIN.

Then I disconnected power and removed Battery.
Insert USB drive in system, Hold Windows+B key, plugged the power and switched on the laptop. when usb drive is load and flashing I released the key combination. Then I heard single single beep sound (before checking time It was 2+1 beep and continous beep sound). After 2-3 minutes system shutdown automatically. Then I removed USB drive and power on the system. Now My system working perfectly.

This blog helped me to fix this issue and