Unable to click on Object, Other Element Would receive click

@HHanh Tran said:

Hi there,

You can try to click on the element using Javascript instead:

- Create a custom keyword and insert script to click on the element using Javascript:
https://docs.katalon.com/display/KD/Define+custom+keywords

Your custom keyword will be like this:

import org.openqa.selenium.WebDriver as WebDriver
import org.openqa.selenium.WebElement as WebElement
import org.openqa.selenium.interactions.Actions as Actions
import com.kms.katalon.core.webui.common.WebUiCommonHelper as WebUiCommonHelper
import com.kms.katalon.core.webui.driver.DriverFactory as DriverFactory
import org.openqa.selenium.JavascriptExecutor as JavascriptExecutor

@Keyword
def clickUsingJS(TestObject to, int timeout)
{
WebDriver driver = DriverFactory.getWebDriver()
WebElement element = WebUiCommonHelper.findWebElement(to, timeout)
JavascriptExecutor executor = ((driver) as JavascriptExecutor)
executor.executeScript('arguments[0].click()', element)
}

Then in your test case replace ‘Click’ action with this custom keyword instead, e.g:
CustomKeywords.‘com.example.WebUIKeywords.clickUsingJS’(findTestObject('Page_Leadership MicroStar Logistic/a_Learn More 1′), 30)

Thanks

It works, ty so much!!!

1 Like