Press and hold home button not detected by Katalon

I have an Android phone that has a feature where pressing and holding the Overview button will close all open apps and pressing and holding the Home button will open up the Google Assistant. Mobile keyword includes Press Home but not press and hold.

I have tried Tap and Hold and Tap and Hold at Position. Tap and Hold does not work as the Home, Back and Overview buttons are not being picked up by the Mobile Spy/Recorder so I can’t define the objects to Tap and Hold. Tap and Hold at Position fails with an error stating
Coordinate [x=540.0, y=2100.0] is outside of element rect: [0,0][1080,2016]

This makes me believe Katalon is not looking below 2016 (where the Home, Back and Overview buttons are). The device full size is 1080 x 2160. Does anyone know how to press and hold on these buttons at the bottom of the screen?

1 Like

@thongnmtran - Sorry to tag you again but your previous advice has been so useful - thank you!

What are your thoughts on this query? In one of my tests I’m also trying to verify element visible on the clock, and battery icon when in battery saver mode which are both at the top of the screen above the Android notifications. In another test, I have an app that loads in full screen mode and some of the buttons are at the bottom of the screen where Katalon is unable to detect whilst running (uiautomater whilst recording/spy tool can interact with these elements fine)

1 Like

Hi @mohammad.arif,

Thanks for remembering me /=)

To press and hold on some button, you could do the same as the previous post, but change the method to driver.“longPressKey”.

import com.kms.katalon.core.mobile.keyword.internal.MobileDriverFactory
import io.appium.java_client.android.AndroidDriver
import io.appium.java_client.MobileElement
import io.appium.java_client.android.nativekey.AndroidKey
import io.appium.java_client.android.nativekey.KeyEvent

AndroidDriver<MobileElement> driver = MobileDriverFactory.getDriver()
driver.longPressKey(new KeyEvent(AndroidKey.HOME))

If this not work, It could be because of not holding long enough. In that case, you could try for some other keys like AndroidKey.POWER to see if this method really does something different.

@thongnmtran Thank you very much, I’ll try this out.

1 Like