Taking a full screenshot of the android device

Ask general questions here.
User avatar
Posts: 28
Joined: Wed Jul 08, 2015 7:50 am

Taking a full screenshot of the android device

Post by sandamal » Mon Aug 24, 2015 2:05 pm


Im automating an android application.
Is there any option in record modules to make a complete screen shot of the Android screen in to the report.

what I found is it is only possible to specify the element and take the screen shot of that. ( when i did not specify the element it took the screen of the Laptop screen - Im connecting the android device via USB to the laptop and running tests on android device )
Using ranorex

please advice :roll:

Posts: 82
Joined: Fri Oct 24, 2014 10:58 am
Location: Bucharest

Re: Taking a full screenshot of the android device

Post by lucian.teodorescu » Mon Aug 24, 2015 4:44 pm

Hi sandamal,

Whenever I need 'the whole picture' I take a screenshot of the application itself (since you test the app, and Ranorex can handle only instrumented apps).
The only time when taking the screenshot is not possible is when the app is closed. Also, any screenshot of the app doesn't capture any device system pop-up.

Maybe you could give us some details in which situation you cannot use screenshot of the entire app.
Meanwhile, here is a "first try" and resources consuming method, with the following steps:
- use adb command to take screenshot
- use adb command to save screenshot to your PC
- log the screenshot to your report
- clean (delete file from device and PC)

Copy-Paste this code into user code module
*** add 'using System.IO;' reference

Code: Select all

string pathToAdb = "C:\\xxxxxxxx\\Android SDK\\sdk\\platform-tools\\adb.exe";   //your path to adb.exe goes here

//take screenshot
Process adbTakeScreenshot = new Process();
adbTakeScreenshot.StartInfo.FileName  = pathToAdb;
adbTakeScreenshot.StartInfo.Arguments = string.Format(" shell screencap /sdcard/Download/myScreenshot.png");

//save screenshot to PC
Process adbGetScreenshot = new Process();
adbGetScreenshot.StartInfo.FileName  = pathToAdb;
adbGetScreenshot.StartInfo.Arguments = string.Format(" pull /sdcard/Download/myScreenshot.png \"C:\\Temp\\screen.bmp\"");
//log your screenshot	into report	Report.LogData(ReportLevel.Info,"Info",Ranorex.Imaging.Load(@"C:\\Temp\\screen.bmp"));
//remove file from USB device
Process adbRemoveFile = new Process();
adbRemoveFile.StartInfo.FileName  = pathToAdb;
adbRemoveFile.StartInfo.Arguments = string.Format(" shell rm /sdcard/Download/myScreenshot.png");
//remove file from your PC
Let us know what solution worked for you, even if is one listed here or not.
Lucian Teodorescu
NetSun Software