Javascript executer to perform click but step doesn't pass even though button is clicked

I am using javascript executer to perform click event as normal click event is not working on my application even though test case is passed saying katalon has clicked on the object but it’s not clicked.

Browser: IE11

WebElement element = WebUiCommonHelper.findWebElement(obj,30)

	WebUI.executeJavaScript("arguments[0].click()", Arrays.asList(element))

from the above code, I am able to click on the button, but whenever the new window gets displayed on clicking button (on a same page) the execution stops at WebUI.executeJavaScript(“arguments[0].click()”, Arrays.asList(element)) and nothing happens. So please anyone have any idea how to deal with this.

When this kind of thing fails silently, it’s usually because you are not clicking on the element you were expecting (most importantly for javascript, the element that triggers an event).

Can you share an HTML snippet of the target element as well as parent elements?

Hi @Harshavardhan_K

In case @Brandon_Hein’s hypothesis is invalidated, you can try this solution.

I did some quick google and found that this bug was reported by people in Selenium, particularly on IE 11. A possible workaround is to insert this line before the click:

WebUI.executeJavaScript("arguments[0].sendKey('')", Arrays.asList(element))

Please try that and see if it resolves the issue. In case that doesn’t work either, here’s the link to the issue on Selenium.

You could try some solutions people suggested there.

Regards !

Thanks, it helped me a lot in understanding things. Now I am able to access element by using offset value of the button

WebUI.clickOffset(findTestObject(‘Object Repository/ICW_PatientEpisodeEditer/MenuOprions/Button_Search’), -1, 0)

1 Like

I also got same issue

Below is the cod i used

WebElement e1=driver.findElement(By.xpath("//div[@id=‘button2’]"));
Actions actions = new Actions(driver);

((JavascriptExecutor) driver).executeScript("arguments[0].scrollIntoView(true);", e1);
((JavascriptExecutor) driver).executeScript("arguments[0].click();", e1);

How to offset this?