Skip to main content

WebUI.click() does not click in some test environments

WebUI.click() keyword is sometimes does not click when executing tests in certain environments, there is no error message.

Selenium WebDriver checks two preconditions when we click a web element:
  • The element must be visible.

  • It must have a height and width greater than 0px.

In the case where the preconditions are not satisfied, you will get exceptions stating the element is not clickable or interactable. But when you use JavaScript click, JavaScript does not check these preconditions and instead go on triggering a click event on the element, even though the element may not be visible. Therefore, we should choose WebDriver and use JavaScript sparingly and only when direct methods of WebDriver doesn't work.
We suggest using the JavascriptExecutor like the sample below instead of using the WebUI.click() keyword:
import com.kms.katalon.core.webui.common.WebUiCommonHelper as WebUiCommonHelper
import org.openqa.selenium.WebElement as WebElement
WebElement element = WebUiCommonHelper.findWebElement(findTestObject('your/object'),30) WebUI.executeJavaScript("arguments[0].click()", Arrays.asList(element))