2013-05-20

How to take a screenshot in robotium?

In this article we are going to see how to take a screenshot in an Android device while performing Unit Testing using robotium framework.

After Initiating solo, we need to use the object of solo.

-To take screenshot with default naming
 solo.takeScreenshot();

-To take screenshot with our given name
solo.takeScreenshot("NameOfTheFile");

-To take screenshot with our given name along with given quality
solo.takeScreenshot("NameOfTheFile",5);

Note :
-Default naming makes the name with current date and time.
-The given quality is measured by compression rate(in integer) 0-100 of the screen shot. 0=lowest size, 100= max quality.
-By default, it saves the screenshot in "/sdcard/Robotium-Screenshots/", So if you are using emulator, do not forget keep an SD card.
-As, it will store, it will need write permission in AndroidManifest.xml
 
(android.permission.WRITE_EXTERNAL_STORAGE)
for latest revision, if we forget to permit this,

Thanks..:)

2013-05-19

How can we parametrize host Information in Jmeter?

In this article we are going to see functions of jmeter used for providing the PC information where jmeter test is running.

Why this is important? It is very important when
-we need to know where the test is runnning
-We need to identify specific request's environment
-We need to use the host information in the reports
-We need identify host to send or receive data.

Jmeter provides some build in set of functions that we can see. I will post a different post for basic idea on jmeter function and a function helper UI for that. In here here we sill see only necessary functions.

- To know the host's IP(where the jmeter is running)
${__machineIP}
Note : ${__machineIP()} This will also work

- To know the host's Name (where the jmeter is running)
${__machineName}
Note : ${__machineName()} This will also work


How can we use?
In place where we need to the function, it means, if we need to identity with a particular thread name, We will add this function before/after the thread name.
In case of any request(such as http), we will do the same. Or, we may use this in pre processor or post processor if we need.

 

This is very useful while we are using Jmeter remotely with multiple hosts for running. We can get which request from which server using this.

Thanks..:) 

2013-05-18

How to press a key in Robotium?

In this article we are going to see how to press hardware keys of an Android device while performing Unit Testing using robotium framework.Now a days, most of the device do not have hardware keys. But, Android handles those keys separately than soft keys.

After Initiating solo, we need to use the object of solo.

 
-To press Up button
solo.sendKey(Solo.UP);

-To press Down
solo.sendKey(Solo.DOWN);

-To press Back button
solo.goBack();

-To press Right
solo.sendKey(Solo.RIGHT);

-To press Left
solo.sendKey(Solo.LEFT);

-To press Enter(Like pressing ok)
solo.sendKey(Solo.ENTER);

-To press Menu
solo.sendKey(Solo.MENU);

-To press Delete
solo.sendKey(Solo.DELETE);

Note ; All of them represents a integer value
RIGHT = 22
LEFT =21
UP=19
DOWN=20
ENTER=66
MENU=82
DELETE =67

If we integer value in place of that static code, it will work perfectly. Like in case of pressing UP
solo.sendKey(19);

Thanks...:) 

How to change alignment in Robotium?

In this article we are going to see how change the alignment of screen of an Android device while performing Uni Testing using robotium framework.

After Initiating solo, we need to use the object of solo. I will make a separate post for getting started with robotium development.

-To make the screen as landscape alignment.
solo.setActivityOrientation(Solo.LANDSCAPE);
Note : solo.LANDSCAPE is an static integer value which is Zero(0). So, if we write like this, it will work. 
solo.setActivityOrientation(0);

-To make the screen as portrait
solo.setActivityOrientation(Solo.PORTRAIT);
Note : solo.PORTRAITis an static integer value which is One(1). So, same function
solo.setActivityOrientation(1);

Thanks...:)