Hi all, I’ve seen a lot of questions about TestObjects cannot be clicked.
This tip is here so that you may have a reference before asking questions about this problem.
Symptoms
Element Click Intercepted
(From this question)
Element not interactable
org.openqa.selenium.ElementNotInteractableException: Cannot click on element
Build info: version: ‘3.7.1’, revision: ‘8a0099a’, time: ‘2017-11-06T21:07:36.161Z’
System info: host: ‘LN446533’, ip: ‘10.2.112.67’, os.name: ‘Windows 10’, os.arch: ‘amd64’, os.version: ‘10.0’, java.version: ‘1.8.0_102’
(From this question)
Element not visible
06-21-2018 12:01:49 PM - [FAILED] - Unable to click on object ‘Object
Repository/Menu_Iteam_MainNavigation/lnk_MainMenuIteam’ (Root cause:
org.openqa.selenium.ElementNotVisibleException: element not visible
(From this question)
Viable solutions that worked
Javascript click
Props to @Russ_Thomas and @Brandon_Hein
Keyword
package util
import org.openqa.selenium.JavascriptExecutor
import org.openqa.selenium.WebDriver
import org.openqa.selenium.WebElement
import com.kms.katalon.core.testobject.TestObject
import com.kms.katalon.core.webui.common.WebUiCommonHelper
import com.kms.katalon.core.webui.driver.DriverFactory
public class Util {
public static void jsClick(final TestObject testObject) {
WebElement element = WebUiCommonHelper.findWebElement(testObject, 30);
WebDriver driver = DriverFactory.getWebDriver();
JavascriptExecutor jsExecutor = (JavascriptExecutor)driver;
jsExecutor.executeScript("arguments[0].click();", element);
}
}
In test case
import com.kms.katalon.core.testobject.ObjectRepository
import com.kms.katalon.core.testobject.TestObject as TestObject
// This is the import statement for the "Util" Custom Keyword we've created:
import util.Util
TestObject myTestObject = ObjectRepository.findTestObject("path/to/my/object");
Util.jsClick(myTestObject);
Wait for element to be clickable
WebUI.waitForElementClickable(findTestObject('Page_CuraHomepage/btn_MakeAppointment'), 20)
Double click
It was said to have worked by @sudam_wellappuli