0

My device has a small RAM capacity and when too many apps are open, it starts to slow down and disturbs the execution of my script.

So I would like to close all the apps open on my smartphone before running my automation script. So my idea was to get the list of all apps open on the device and then kill them one by one with the command:

driver.terminate_app('PACKAGE_NAME')

But I didn't find how to get a list of the open apps on a device.

Gauthier Buttez
  • 1,005
  • 1
  • 16
  • 40

1 Answers1

0

I don't know about Appium, but to list all currently running third party apps via adb (Android Debug Bridge) it is the following command:

 adb shell pm list packages -e -3
Alpa
  • 71
  • 1
  • 3
  • Thanks, but it obviously give all the 3rd party apps installed in device, not the one open. – Gauthier Buttez Oct 24 '22 at 09:04
  • You are correct. However, you could iterate over that list and try closing everything in it, or run `adb shell pidof com.my.package` to see if that particular package is currently running. If it is running, the command will return a process id. This is obviously not an Appium based solution, but after skimming their documentation, I didn't see them having that function. – Alpa Oct 24 '22 at 10:03