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..:)

4 comments:

  1. Simply great!

    ReplyDelete
  2. it does not take the screen shot, can you tell me clearly about how to take screenshot.

    ReplyDelete
    Replies
    1. It takes screenshot in Sd card. Please keep sd card in avd. after taking screenshot, you can see those from Calgary of adv or device.

      Delete