How to perform LONG press on (physical )Home button?

I need to perform LONG press on my physical home button (JAVA).
10x in advance

There is no way you can access the hardware buttons using appium

Can you explain what is your scenario, there might be an alternative way to achieve that.

i want to see all the open apps in the background and close some app.
10x.

I think you referring to Android. In that case run

adb shell input keyevent KEYCODE_APP_SWITCH

In case you do not know how. In Java just do:

Runtime.getRuntime().exec("command in here");

If you have more than one device use -s id where id is your device id:

adb -s id shell input keyevent KEYCODE_APP_SWITCH
2 Likes

Talking only about Android . You can also try automating above process

  1. Press Android Home button using driver.pressKeyCode(AndroidKeyCode.HOME);
  2. Launch Settings app using driver.startActivity(“settings app package”,“settings app launcher”)
  3. Click Apps driver.scrollToExact(“Apps”).click()
  4. Swipe horizontal right using driver.swipe(100,100,300,100); so that u move to runnings tab
  5. Perform action u want over running apps

I tried to perform your suggestion but this command always been ignored.
Runtime.getRuntime().exec(“adb shell input keyevent KEYCODE_APP_SWITCH”);
Anything I should perform before?
Thanks

Have you run command in terminal

adb shell input keyevent KEYCODE_APP_SWITCH

with only one android connected. Whats the device model you using. It works for the ones I have here.