austgl / robotium

Automatically exported from code.google.com/p/robotium
0 stars 0 forks source link

New Featrue Request: Capture screenshot functionality. #22

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Would it be possible to provide Capture Screenshot when an assertion fails in 
solo.

It would be better to provide a method like captureScreenshot which test case 
can also call.

I am not sure how the screenshots will be transferred to desktop though.

Benefits: This would really help in analyzing why things failed or how was the 
state of application when some assert failed.

Original issue reported on code.google.com by aman.bha...@gmail.com on 16 Oct 2010 at 2:16

GoogleCodeExporter commented 9 years ago
The problem with adding this functionality is that a security tag is needed in 
the application under test that allows of saving the screenshot. So basically 
anyone who wants to use Robotium must add that security permission tag to the 
AndroidManifest.xml of the application under test. That is not something that 
we can require all Robotium users to do. Thus we have not included this feature 
into Robotium.

Original comment by renasr...@gmail.com on 16 Oct 2010 at 2:34

GoogleCodeExporter commented 9 years ago
I actually control the build of my app and I am thinking writing small piece of 
code to do this.
Could you please point me to some code to do this.

Thanks a lot for quick updates.

Original comment by aman.bha...@gmail.com on 16 Oct 2010 at 3:08

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
Hi there i know the answer what i am posting was too late but it would help 
someone out there, i got the help form the link 
http://softteco.blogspot.com/2011/04/android-take-screenshot.html

If you can't get to the link 

just try the below code

// set your location
private static final String SCREEN_SHOTS_LOCATION = "/media/screenshots";

public static void takeScreenShot(View view, String name) throws Exception {
view.setDrawingCacheEnabled(true);
view.buildDrawingCache();
Bitmap b = view.getDrawingCache();
FileOutputStream fos = null;
try {
File sddir = new File(SCREEN_SHOTS_LOCATION);
if (!sddir.exists()) {
sddir.mkdirs();
}
fos = new FileOutputStream(SCREEN_SHOTS_LOCATION + name + "_"
+ System.currentTimeMillis() + ".jpg");
if (fos != null) {
b.compress(Bitmap.CompressFormat.JPEG, 90, fos);
fos.close();
}
} catch (Exception e) {
}
}

Call:

Utils.takeScreenShot(solo.getViews().get(0), getName());

cheers
RanjithkumarRagavan
Enterprise Mobile Developer
ProkarmaSoftech pvt.lt
Chennai

Original comment by rranj...@prokarmasoftech.com on 6 Jan 2012 at 11:18