Closed GoogleCodeExporter closed 9 years ago
takeScreenshot() requires one to add the permission tag to the application
under test (AUT). Not the test project! The reason why your code works is that
you are not saving it to sdcard. Therefore you do not need the permission tag
in your application under test. Will open up this issue if behaviour of
takeScreenshot() is modified to save to internal when permission is not
present.
Original comment by renasr...@gmail.com
on 21 Aug 2012 at 9:34
Until there is an official release, I would like to contribute my personal hack
which works even when JUnit starts via command line,
I used it with JUnit during the execution of different activities as well as
during the dearDown();
public void takeScreenshot(final String filename) {
sleep(2000); //hack to ensure that the current view has been fully loaded
View view = m_solo.getCurrentViews(FrameLayout.class).get(0).getRootView();
view.setDrawingCacheEnabled(true);
view.buildDrawingCache();
Bitmap bitmap = view.getDrawingCache();
File directory = new File("/mnt/sdcard/Robotium-Screenshots/");
directory.mkdirs();
if (bitmap != null) {
try {
File outputFile = new File(directory, filename + ".jpg");
FileOutputStream ostream = new FileOutputStream(outputFile);
bitmap.compress(CompressFormat.JPEG, 100, ostream);
ostream.close();
} catch (Exception e) {
logError(e.getMessage());
}
}
}
Original comment by d...@zarafonitis.com
on 11 Jun 2013 at 11:11
Original issue reported on code.google.com by
teja...@gmail.com
on 21 Aug 2012 at 8:46