We are working on TestComplete automation tool for automating Test scripts for android device. How to get to know all the processes running in a android device using shell script or TestComplete script?
Asked
Active
Viewed 848 times
0
-
2This seems like a duplicate: http://stackoverflow.com/questions/3278895/how-to-check-current-running-applications-in-android – Sipty Aug 19 '15 at 09:45
-
@Sipty: Not a duplicate. This question is about writing automated tests for Android, not writing Android apps. – Helen Aug 19 '15 at 12:28
-
Do you need to check if a specific process is running (as the title says), or list all processes (as the post says)? – Helen Aug 19 '15 at 13:34
1 Answers
0
This lists all running processes that were instrumented for TestComplete:
function Test()
{
Mobile.SetCurrent("emulator-5554");
var device = Mobile.Device();
for (var i = 0; i < device.ChildCount; i++)
{
Log.Message(device.Child(i).ProcessName);
}
}
To list ALL running process, you can use the adb shell ps
command. You can run it from TestComplete like this:
function Test()
{
Mobile.SetCurrent("emulator-5554");
var str = Mobile.Device().ShellExecute("ps");
Log.Message("See Additional Info", str);
}
But you'll need to filter the command's output, because it looks like:
USER PID PPID VSIZE RSS WCHAN PC NAME
root 1 0 9128 808 c02b4929 0806c150 S /init
root 2 0 0 0 c023172d 00000000 S kthreadd
system 1238 949 599324 84032 ffffffff b7503355 S system_server
u0_a12 1438 949 520712 56672 ffffffff b7503355 S com.android.systemui
u0_a2 1457 949 491816 32504 ffffffff b7503355 S android.process.acore

Helen
- 87,344
- 17
- 243
- 314