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

I am also having similar issue while trying to run the test on Pixel 4 and Pixel 4 XL with Android 11 and API 30. But this error is not happening on Pixel 3a or Pixel 3 simulator. Same error is observed on real device Samsung Galaxy S20FE. When I tried to device width and height the Kalaton is showing different size than the actual device size. Please let me know if anyone have a solution or workaround for this.

Thank you,
NG

`=============== ROOT CAUSE =====================

For trouble shooting, please visit: https://docs.katalon.com/katalon-studio/docs/troubleshoot-common-execution-exceptions-web-test.html

12-14-2020 10:35:35 AM tap(findTestObject(“Object Repository/PetSafe PageObjects/User Home Page/Scoop Free/Scoop Free - SETTINGS”), 3, CONTINUE_ON_FAILURE)

Elapsed time: 3.765s

Failed to tap on element ‘Object Repository/PetSafe PageObjects/User Home Page/Scoop Free/Scoop Free - SETTINGS’ (Root cause: org.openqa.selenium.InvalidArgumentException: Coordinate [x=1158.0, y=2793.0] is outside of element rect: [0,0][1440,2701]
Build info: version: ‘3.141.59’, revision: ‘e82be7d358’, time: ‘2018-11-14T08:25:53’
System info: host: ‘Ithelps-MacBook-Pro.local’, ip: ‘fe80:0:0:0:1c07:f32e:beb9:a5ad%en0’, os.name: ‘Mac OS X’, os.arch: ‘x86_64’, os.version: ‘10.16’, java.version: ‘1.8.0_181’
Driver info: com.kms.katalon.core.appium.driver.SwipeableAndroidDriver
Capabilities {app: /Users/ngeo091420/Desktop/K…, appPackage: net.petsafe.platform, autoGrantPermissions: true, automationName: uiautomator2, chromedriverPort: 53985, databaseEnabled: false, desired: {app: /Users/ngeo091420/Desktop/K…, autoGrantPermissions: true, automationName: uiautomator2, chromedriverPort: 53985, deviceId: , deviceName: emulator-5554 (sdk_gphone_x…, fullReset: false, newCommandTimeout: 1800, noReset: true, platform: ANDROID, platformName: android, platformVersion: 11, systemPort: 53983, udid: emulator-5554}, deviceApiLevel: 30, deviceId: , deviceManufacturer: Google, deviceModel: sdk_gphone_x86_arm, deviceName: emulator-5554, deviceScreenDensity: 560, deviceScreenSize: 1440x3040, deviceUDID: emulator-5554, fullReset: false, javascriptEnabled: true, locationContextEnabled: false, networkConnectionEnabled: true, newCommandTimeout: 1800, noReset: true, pixelRatio: 3.5, platform: ANDROID, platformName: Android, platformVersion: 11, statBarHeight: 172, systemPort: 53983, takesScreenshot: true, udid: emulator-5554, viewportRect: {height: 2529, left: 0, top: 172, width: 1440}, warnings: {}, webStorageEnabled: false}
Session ID: cc7efa5c-7ba3-413e-88a2-96ff437c8e71
at org.openqa.selenium.remote.http.W3CHttpResponseCodec.createException(W3CHttpResponseCodec.java:187)
at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:122)
at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:49)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:158)
at io.appium.java_client.remote.AppiumCommandExecutor.execute(AppiumCommandExecutor.java:239)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:552)
at io.appium.java_client.DefaultGenericMobileDriver.execute(DefaultGenericMobileDriver.java:42)
at io.appium.java_client.AppiumDriver.execute(AppiumDriver.java:1)
at io.appium.java_client.android.AndroidDriver.execute(AndroidDriver.java:1)
at com.kms.katalon.core.appium.driver.SwipeableAndroidDriver.execute(SwipeableAndroidDriver.java:1)
at io.appium.java_client.PerformsTouchActions.performTouchAction(PerformsTouchActions.java:41)
at io.appium.java_client.TouchAction.perform(TouchAction.java:187)
at com.kms.katalon.core.mobile.keyword.builtin.TapKeyword$_tap_closure1.doCall(TapKeyword.groovy:84)
at com.kms.katalon.core.mobile.keyword.builtin.TapKeyword$_tap_closure1.call(TapKeyword.groovy)
at com.kms.katalon.core.mobile.keyword.internal.MobileKeywordMain.runKeyword(MobileKeywordMain.groovy:21)
at com.kms.katalon.core.mobile.keyword.builtin.TapKeyword.tap(TapKeyword.groovy:86)
at com.kms.katalon.core.mobile.keyword.builtin.TapKeyword.execute(TapKeyword.groovy:68)
at com.kms.katalon.core.keyword.internal.KeywordExecutor.executeKeywordForPlatform(KeywordExecutor.groovy:73)
at com.kms.katalon.core.mobile.keyword.MobileBuiltInKeywords.tap(MobileBuiltInKeywords.groovy:563)
at com.kms.katalon.core.mobile.keyword.MobileBuiltInKeywords$tap$6.call(Unknown Source)
at ScoopFree.scoopFreeSettings(ScoopFree:123)
at Script1607680915236$scoopFreeSettings.callCurrent(Unknown Source)
at ScoopFree.scoopFree(ScoopFree:73)
at ScoopFree.run(ScoopFree:26)
at com.kms.katalon.core.main.ScriptEngine.run(ScriptEngine.java:194)
at com.kms.katalon.core.main.ScriptEngine.runScriptAsRawText(ScriptEngine.java:119)
at com.kms.katalon.core.main.TestCaseExecutor.runScript(TestCaseExecutor.java:339)
at com.kms.katalon.core.main.TestCaseExecutor.doExecute(TestCaseExecutor.java:330)
at com.kms.katalon.core.main.TestCaseExecutor.processExecutionPhase(TestCaseExecutor.java:309)
at com.kms.katalon.core.main.TestCaseExecutor.accessMainPhase(TestCaseExecutor.java:301)
at com.kms.katalon.core.main.TestCaseExecutor.execute(TestCaseExecutor.java:235)
at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:114)
at com.kms.katalon.core.keyword.builtin.CallTestCaseKeyword$_callTestCase_closure1.doCall(CallTestCaseKeyword.groovy:59)
at com.kms.katalon.core.keyword.builtin.CallTestCaseKeyword$_callTestCase_closure1.call(CallTestCaseKeyword.groovy)
at com.kms.katalon.core.keyword.internal.KeywordMain.runKeyword(KeywordMain.groovy:68)
at com.kms.katalon.core.keyword.builtin.CallTestCaseKeyword.callTestCase(CallTestCaseKeyword.groovy:81)
at com.kms.katalon.core.keyword.builtin.CallTestCaseKeyword.execute(CallTestCaseKeyword.groovy:44)
at com.kms.katalon.core.keyword.internal.KeywordExecutor.executeKeywordForPlatform(KeywordExecutor.groovy:73)
at com.kms.katalon.core.keyword.BuiltinKeywords.callTestCase(BuiltinKeywords.groovy:334)
at Product Testing.findproduct(Product Testing:76)
at Product Testing.run(Product Testing:37)
at com.kms.katalon.core.main.ScriptEngine.run(ScriptEngine.java:194)
at com.kms.katalon.core.main.ScriptEngine.runScriptAsRawText(ScriptEngine.java:119)
at com.kms.katalon.core.main.TestCaseExecutor.runScript(TestCaseExecutor.java:339)
at com.kms.katalon.core.main.TestCaseExecutor.doExecute(TestCaseExecutor.java:330)
at com.kms.katalon.core.main.TestCaseExecutor.processExecutionPhase(TestCaseExecutor.java:309)
at com.kms.katalon.core.main.TestCaseExecutor.accessMainPhase(TestCaseExecutor.java:301)
at com.kms.katalon.core.main.TestCaseExecutor.execute(TestCaseExecutor.java:235)
at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:114)
at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:105)
at com.kms.katalon.core.main.TestCaseMain$runTestCase$0.call(Unknown Source)
at TempTestCase1607942101068.run(TempTestCase1607942101068.groovy:25)
)`

Hi @ngeorge,

It’s because your element is not in the current viewport. You can add Scroll To Text keyword before clicking on the object.

Mobile.scrollToText('Text of element')
Mobile.tap(findTestObject(“Object Repository/PetSafe PageObjects/User Home Page/Scoop Free/Scoop Free - SETTINGS”), 3, CONTINUE_ON_FAILURE)

Thank you @duyluong. I tried adding scrollToText. But same error is shown

=============== ROOT CAUSE =====================
Caused by: org.openqa.selenium.InvalidArgumentException: Coordinate [x=864.0, y=2086.0] is outside of element rect: [0,0][1080,1977]

For trouble shooting, please visit: https://docs.katalon.com/katalon-studio/docs/troubleshoot-common-execution-exceptions-web-test.html
================================================

12-15-2020 11:16:42 AM Test Cases/Test testcases/Select Product

Elapsed time: 25.974s

Test Cases/Test testcases/Select Product FAILED.
Reason:
com.kms.katalon.core.exception.StepFailedException: Failed to tap on element 'Object Repository/PetSafe PageObjects/User Home Page/Scoop Free/Scoop Free - SETTINGS' (Root cause: org.openqa.selenium.InvalidArgumentException: Coordinate [x=864.0, y=2086.0] is outside of element rect: [0,0][1080,1977]
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:25:53'
System info: host: 'Ithelps-MacBook-Pro.local', ip: 'fe80:0:0:0:1c07:f32e:beb9:a5ad%en0', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.16', java.version: '1.8.0_181'
Driver info: com.kms.katalon.core.appium.driver.SwipeableAndroidDriver
Capabilities {app: /Users/ngeo091420/Desktop/K..., appPackage: net.petsafe.platform, autoGrantPermissions: true, automationName: uiautomator2, chromedriverPort: 64666, databaseEnabled: false, desired: {app: /Users/ngeo091420/Desktop/K..., autoGrantPermissions: true, automationName: uiautomator2, chromedriverPort: 64666, deviceId: , deviceName: emulator-5554 (sdk_gphone_x..., fullReset: false, newCommandTimeout: 1800, noReset: true, platform: ANDROID, platformName: android, platformVersion: 11, systemPort: 64664, udid: emulator-5554}, deviceApiLevel: 30, deviceId: , deviceManufacturer: Google, deviceModel: sdk_gphone_x86, deviceName: emulator-5554, deviceScreenDensity: 440, deviceScreenSize: 1080x2280, deviceUDID: emulator-5554, fullReset: false, javascriptEnabled: true, locationContextEnabled: false, networkConnectionEnabled: true, newCommandTimeout: 1800, noReset: true, pixelRatio: 2.75, platform: ANDROID, platformName: Android, platformVersion: 11, statBarHeight: 135, systemPort: 64664, takesScreenshot: true, udid: emulator-5554, viewportRect: {height: 1842, left: 0, top: 135, width: 1080}, warnings: {}, webStorageEnabled: false}
Session ID: a9a04f77-b955-4eb4-a99a-453b0bec5eec
	at org.openqa.selenium.remote.http.W3CHttpResponseCodec.createException(W3CHttpResponseCodec.java:187)
	at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:122)
	at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:49)
	at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:158)
	at io.appium.java_client.remote.AppiumCommandExecutor.execute(AppiumCommandExecutor.java:239)
	at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:552)
	at io.appium.java_client.DefaultGenericMobileDriver.execute(DefaultGenericMobileDriver.java:42)
	at io.appium.java_client.AppiumDriver.execute(AppiumDriver.java:1)
	at io.appium.java_client.android.AndroidDriver.execute(AndroidDriver.java:1)
	at com.kms.katalon.core.appium.driver.SwipeableAndroidDriver.execute(SwipeableAndroidDriver.java:1)
	at io.appium.java_client.PerformsTouchActions.performTouchAction(PerformsTouchActions.java:41)
	at io.appium.java_client.TouchAction.perform(TouchAction.java:187)
	at com.kms.katalon.core.mobile.keyword.builtin.TapKeyword$_tap_closure1.doCall(TapKeyword.groovy:84)
	at com.kms.katalon.core.mobile.keyword.builtin.TapKeyword$_tap_closure1.call(TapKeyword.groovy)
	at com.kms.katalon.core.mobile.keyword.internal.MobileKeywordMain.runKeyword(MobileKeywordMain.groovy:21)
	at com.kms.katalon.core.mobile.keyword.builtin.TapKeyword.tap(TapKeyword.groovy:86)
	at com.kms.katalon.core.mobile.keyword.builtin.TapKeyword.execute(TapKeyword.groovy:68)
	at com.kms.katalon.core.keyword.internal.KeywordExecutor.executeKeywordForPlatform(KeywordExecutor.groovy:73)
	at com.kms.katalon.core.mobile.keyword.MobileBuiltInKeywords.tap(MobileBuiltInKeywords.groovy:577)
	at com.kms.katalon.core.mobile.keyword.MobileBuiltInKeywords$tap$3.call(Unknown Source)
	at Select Product.scoopFree(Select Product:99)
	at Select Product.findproduct(Select Product:81)
	at Select Product.run(Select Product:40)
	at com.kms.katalon.core.main.ScriptEngine.run(ScriptEngine.java:194)
	at com.kms.katalon.core.main.ScriptEngine.runScriptAsRawText(ScriptEngine.java:119)
	at com.kms.katalon.core.main.TestCaseExecutor.runScript(TestCaseExecutor.java:339)
	at com.kms.katalon.core.main.TestCaseExecutor.doExecute(TestCaseExecutor.java:330)
	at com.kms.katalon.core.main.TestCaseExecutor.processExecutionPhase(TestCaseExecutor.java:309)
	at com.kms.katalon.core.main.TestCaseExecutor.accessMainPhase(TestCaseExecutor.java:301)
	at com.kms.katalon.core.main.TestCaseExecutor.execute(TestCaseExecutor.java:235)
	at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:114)
	at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:105)
	at com.kms.katalon.core.main.TestCaseMain$runTestCase$0.call(Unknown Source)
	at TempTestCase1608031001119.run(TempTestCase1608031001119.groovy:25)
)
	at com.kms.katalon.core.keyword.internal.KeywordMain.stepFailed(KeywordMain.groovy:50)
	at com.kms.katalon.core.mobile.keyword.internal.MobileKeywordMain.stepFailed(MobileKeywordMain.groovy:40)
	at com.kms.katalon.core.mobile.keyword.internal.MobileKeywordMain.runKeyword(MobileKeywordMain.groovy:23)
	at com.kms.katalon.core.mobile.keyword.builtin.TapKeyword.tap(TapKeyword.groovy:86)
	at com.kms.katalon.core.mobile.keyword.builtin.TapKeyword.execute(TapKeyword.groovy:68)
	at com.kms.katalon.core.keyword.internal.KeywordExecutor.executeKeywordForPlatform(KeywordExecutor.groovy:73)
	at com.kms.katalon.core.mobile.keyword.MobileBuiltInKeywords.tap(MobileBuiltInKeywords.groovy:577)
	at com.kms.katalon.core.mobile.keyword.MobileBuiltInKeywords$tap$3.call(Unknown Source)
	at Select Product.scoopFree(Select Product:99)
	at Select Product.findproduct(Select Product:81)
	at Select Product.run(Select Product:40)
	at com.kms.katalon.core.main.ScriptEngine.run(ScriptEngine.java:194)
	at com.kms.katalon.core.main.ScriptEngine.runScriptAsRawText(ScriptEngine.java:119)
	at com.kms.katalon.core.main.TestCaseExecutor.runScript(TestCaseExecutor.java:339)
	at com.kms.katalon.core.main.TestCaseExecutor.doExecute(TestCaseExecutor.java:330)
	at com.kms.katalon.core.main.TestCaseExecutor.processExecutionPhase(TestCaseExecutor.java:309)
	at com.kms.katalon.core.main.TestCaseExecutor.accessMainPhase(TestCaseExecutor.java:301)
	at com.kms.katalon.core.main.TestCaseExecutor.execute(TestCaseExecutor.java:235)
	at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:114)
	at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:105)
	at com.kms.katalon.core.main.TestCaseMain$runTestCase$0.call(Unknown Source)
	at TempTestCase1608031001119.run(TempTestCase1608031001119.groovy:25)
Caused by: org.openqa.selenium.InvalidArgumentException: Coordinate [x=864.0, y=2086.0] is outside of element rect: [0,0][1080,1977]
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:25:53'
System info: host: 'Ithelps-MacBook-Pro.local', ip: 'fe80:0:0:0:1c07:f32e:beb9:a5ad%en0', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.16', java.version: '1.8.0_181'
Driver info: com.kms.katalon.core.appium.driver.SwipeableAndroidDriver
Capabilities {app: /Users/ngeo091420/Desktop/K..., appPackage: net.petsafe.platform, autoGrantPermissions: true, automationName: uiautomator2, chromedriverPort: 64666, databaseEnabled: false, desired: {app: /Users/ngeo091420/Desktop/K..., autoGrantPermissions: true, automationName: uiautomator2, chromedriverPort: 64666, deviceId: , deviceName: emulator-5554 (sdk_gphone_x..., fullReset: false, newCommandTimeout: 1800, noReset: true, platform: ANDROID, platformName: android, platformVersion: 11, systemPort: 64664, udid: emulator-5554}, deviceApiLevel: 30, deviceId: , deviceManufacturer: Google, deviceModel: sdk_gphone_x86, deviceName: emulator-5554, deviceScreenDensity: 440, deviceScreenSize: 1080x2280, deviceUDID: emulator-5554, fullReset: false, javascriptEnabled: true, locationContextEnabled: false, networkConnectionEnabled: true, newCommandTimeout: 1800, noReset: true, pixelRatio: 2.75, platform: ANDROID, platformName: Android, platformVersion: 11, statBarHeight: 135, systemPort: 64664, takesScreenshot: true, udid: emulator-5554, viewportRect: {height: 1842, left: 0, top: 135, width: 1080}, warnings: {}, webStorageEnabled: false}
Session ID: a9a04f77-b955-4eb4-a99a-453b0bec5eec
	at org.openqa.selenium.remote.http.W3CHttpResponseCodec.createException(W3CHttpResponseCodec.java:187)
	at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:122)
	at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:49)
	at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:158)
	at io.appium.java_client.remote.AppiumCommandExecutor.execute(AppiumCommandExecutor.java:239)
	at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:552)
	at io.appium.java_client.DefaultGenericMobileDriver.execute(DefaultGenericMobileDriver.java:42)
	at io.appium.java_client.AppiumDriver.execute(AppiumDriver.java:1)
	at io.appium.java_client.android.AndroidDriver.execute(AndroidDriver.java:1)
	at com.kms.katalon.core.appium.driver.SwipeableAndroidDriver.execute(SwipeableAndroidDriver.java:1)
	at io.appium.java_client.PerformsTouchActions.performTouchAction(PerformsTouchActions.java:41)
	at io.appium.java_client.TouchAction.perform(TouchAction.java:187)
	at com.kms.katalon.core.mobile.keyword.builtin.TapKeyword$_tap_closure1.doCall(TapKeyword.groovy:84)
	at com.kms.katalon.core.mobile.keyword.builtin.TapKeyword$_tap_closure1.call(TapKeyword.groovy)
	at com.kms.katalon.core.mobile.keyword.internal.MobileKeywordMain.runKeyword(MobileKeywordMain.groovy:21)
	... 19 more

Is it solved?

@we.ayt No. I am still having the issue.

There was not this problem on windows system,but It happened on the MacOS system.

@we.ayt Is there any work around for this issue on MAC. I can’t reach anyone at Katalon to ask for solution.

Thank you
-NG

No,I did not have solution.

I can’t reach anyone at Katalon to ask for solution.

Me too. :sweat:

@ngeorge, @we.ayt

You guys can try this script as a workaround:

import static com.kms.katalon.core.testobject.ObjectRepository.findTestObject
import com.kms.katalon.core.mobile.helper.MobileElementCommonHelper
import io.appium.java_client.MobileElement

MobileElement element = MobileElementCommonHelper.findElement(findTestObject('element id'), 10)
element.click()
1 Like

Thank you so much!It was effect! :grinning:

Worked for me too!!!
Thank you @duyluong