I'm running scenarios in UIAutomator.My output is displayed in CMD prompt. Whenever there is a failure i'm printing strings (displayed in Cmd prompt). When the scenarios fails, Is it possible to print the log snippet from logcat logs to cmd prompt?
Asked
Active
Viewed 864 times
1 Answers
0
Late Answer, but better late than never ;-)
You can construct a BufferedReader that reads from logcat like this:
BufferedReader bufferedReader = new BufferedReader(
new InputStreamReader(Runtime.getRuntime().exec("logcat -d").getInputStream()));
and then continue using BufferedReader
for getting the text content as usual and print for example to Cmd prompt as you wanted.
Not sure if that is the best practice doing it this way, but it works.

donfuxx
- 11,277
- 6
- 44
- 76
-
you are mentioning to create a method and calling it?. Can you pass the full code(how to get the text content and print)? – user3135727 Mar 05 '14 at 15:48
-
This works:)however it takes the current logs running in the background.Is it possible to save the logcat log in the temp location of my phone and if my test fails, from logcat log all the error messages to be printed in the Cmd prompt. – user3135727 Mar 06 '14 at 03:54
-
see this answer: http://stackoverflow.com/a/8982342/2399024 maybe that works for your needs – donfuxx Mar 07 '14 at 18:39