Test scripts are failing in headless mode with exception "ElementNotInteractable"

Hi everyone,

First I am executing the testcase in katalon studio on normal browser and then once push the code to git, executing it from TestOps.

It is failing on TestOps with multiple reasons few i am able to resolve but not all.

Mainly errors are like “element click intercepted” ,I tried to resolve the issue by giving the statement

  1. WebUI.waitForElementClickable(findTestObject(‘Object Repository/Page_DemoBlaze/span_’),60)
  2. WebUI.click(findTestObject(‘Object Repository/Page_DemoBlaze/span_’))

I analyzed and found that the same issue when i run using headless mode on local as well. This issue araising due to headless mode runs bit faster than head mode and hence found the solution is wait for the element and click but still that is not working.

I found another solution for this is to configure disredcapabilities with --window-size=1920,1080 but still I am getting the same issue.

How i can resolve it? Thank you very much in advance!

1 Like

Hi,

I found this similar suggestion: Katalon says element not interactable - #2 by Dave_Evers. Can you please try?

I am running into the same issue here. My tests run fine in Chrome normally, but when I switch to headless mode the objects are not interactable. I have tried all the solutions I have found here.

Verify CASSing Works (headless) - 2: waitForElementPresent(findTestObject("TEM/CPNet/Page_CertifiedPro.NET/toolbar_SingleTransaction"), 10)
scrollToElement(findTestObject("TEM/CPNet/Page_CertifiedPro.NET/toolbar_SingleTransaction"), 10)
waitForElementClickable(findTestObject("TEM/CPNet/Page_CertifiedPro.NET/toolbar_SingleTransaction"), 10)
click(findTestObject("TEM/CPNet/Page_CertifiedPro.NET/toolbar_SingleTransaction"))
ERROR c.k.k.core.keyword.internal.KeywordMain  - ❌ Unable to click on object 'Object Repository/TEM/CPNet/Page_CertifiedPro.NET/toolbar_SingleTransaction' (Root cause: com.kms.katalon.core.exception.StepFailedException: Unable to click on object 'Object Repository/TEM/CPNet/Page_CertifiedPro.NET/toolbar_SingleTransaction'

Hi

Have you tried some waits as the suggestion above? I suspect that there might be some late loading. As well, please try to follow this advice: Katalon Help Center

An issue I see with your code is that you want to move to the object, “toolbar_SingleTransaction” using “scrollToElement()” and then, eventually, click on it. What I have found is that the “scrollToElement()” doesn’t necessary scroll so that your object is the first item at the top of the page but is often off the viewport and hidden off the page (unless it is a large textbox and then only the bottom part of the object shows). So, what you can try is to scroll to another object that is about 2" or 5cm above the “toolbar_SingleTransaction” object, so that you know your object will be on screen or you can use your object in something like below:

import com.kms.katalon.core.webui.common.WebUiCommonHelper as WebHelper

WebElement item = WebHelper.getWebElement(findTestObject("TEM/CPNet/Page_CertifiedPro.NET/toolbar_SingleTransaction"), 10)
WebUI.scrollToPosition(100, item.getLocation().getY() - 100)

WebUI.waitForElementVisible(findTestObject("TEM/CPNet/Page_CertifiedPro.NET/toolbar_SingleTransaction"), 10)
WebUI.click(findTestObject("TEM/CPNet/Page_CertifiedPro.NET/toolbar_SingleTransaction"))

Edit: instead of hard coding the “- 100”, maybe you can use the object’s height within the formula, like below. See if this works for you.

import com.kms.katalon.core.webui.common.WebUiCommonHelper as WebHelper

WebElement item = WebHelper.getWebElement(findTestObject("TEM/CPNet/Page_CertifiedPro.NET/toolbar_SingleTransaction"), 10)
WebUI.scrollToPosition(100, item.getLocation().getY() - WebUI.getHeight(findTestObject("TEM/CPNet/Page_CertifiedPro.NET/toolbar_SingleTransaction")))

WebUI.waitForElementVisible(findTestObject("TEM/CPNet/Page_CertifiedPro.NET/toolbar_SingleTransaction"), 10)
WebUI.click(findTestObject("TEM/CPNet/Page_CertifiedPro.NET/toolbar_SingleTransaction"))