Clicking using javascript does not execute in headless mode

Hello,

I have this javascript to click an export button:

WebElement ExportEventReport = WebUiCommonHelper.findWebElement(findTestObject(‘Object Repository/button_FMS_Status_Event Report_Export to CSV’), 30)
WebUI.executeJavaScript(‘arguments[0].click()’, Arrays.asList(ExportEventReport))

It is working when executed with browser UI (not headless).

But when I execute it in headless mode, it does not click the button, nothing was downloaded.

Console:

SLF4J: The requested version 1.7.16 by your slf4j binding is not compatible with [1.6]
SLF4J: See SLF4J Error Codes for further details.
2019-07-04 14:50:41.313 INFO c.k.katalon.core.main.TestCaseExecutor - --------------------
2019-07-04 14:50:41.315 INFO c.k.katalon.core.main.TestCaseExecutor - START Test Cases/Asana Task/Download PDF and Export Functions/FMS_Status_Event Report_ExportToCSV
2019-07-04 14:50:41.730 DEBUG t.FMS_Status_Event Report_ExportToCSV - 1: openBrowser(“”)
2019-07-04 14:50:41.965 INFO c.k.k.core.webui.driver.DriverFactory - Starting ‘Chrome (headless)’ driver
Jul 04, 2019 2:50:41 PM org.openqa.selenium.remote.DesiredCapabilities chrome
INFO: Using new ChromeOptions() is preferred to DesiredCapabilities.chrome()
2019-07-04 14:50:41.980 INFO c.k.k.c.w.util.WebDriverPropertyUtil - User set preference: [‘args’, ‘[–start-maximized, --config -webui.autoUpdateDrivers=true]’]
2019-07-04 14:50:41.997 INFO c.k.k.core.webui.driver.DriverFactory - Action delay is set to 0 seconds
Starting ChromeDriver 75.0.3770.90 (a6dcaf7e3ec6f70a194cc25e8149475c6590e025-refs/branch-heads/3770@{#1003}) on port 18792
Only local connections are allowed.
Please protect ports used by ChromeDriver and related test frameworks to prevent access by malicious code.
Jul 04, 2019 2:50:44 PM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Detected dialect: W3C
2019-07-04 14:50:44.816 INFO c.k.k.core.webui.driver.DriverFactory - sessionId = b6e41750384fb8eff73c57f4058559e5
2019-07-04 14:50:44.843 INFO c.k.k.core.webui.driver.DriverFactory - browser = Chrome 75.0.3770.100
2019-07-04 14:50:44.844 INFO c.k.k.core.webui.driver.DriverFactory - platform = Windows 10
2019-07-04 14:50:44.844 INFO c.k.k.core.webui.driver.DriverFactory - seleniumVersion = 3.141.59
2019-07-04 14:50:44.845 INFO c.k.k.core.webui.driver.DriverFactory - proxyInformation = ProxyInformation{proxyOption=NO_PROXY, proxyServerType=HTTP, password=, proxyServerAddress=, proxyServerPort=0}
2019-07-04 14:50:44.847 DEBUG t.FMS_Status_Event Report_ExportToCSV - 2: navigateToUrl(StagingServerURL_CCM, CONTINUE_ON_FAILURE)
2019-07-04 14:51:10.347 DEBUG t.FMS_Status_Event Report_ExportToCSV - 3: setText(findTestObject(“Object Repository/input_Login_Username_ctl00bodyuserName”), Username, CONTINUE_ON_FAILURE)
2019-07-04 14:51:10.487 DEBUG t.FMS_Status_Event Report_ExportToCSV - 4: setEncryptedText(findTestObject(“Object Repository/input_Login_Password_ctl00bodypassword”), Password, CONTINUE_ON_FAILURE)
2019-07-04 14:51:10.601 DEBUG t.FMS_Status_Event Report_ExportToCSV - 5: click(findTestObject(“Object Repository/button_Login”))
2019-07-04 14:51:11.937 DEBUG t.FMS_Status_Event Report_ExportToCSV - 6: click(findTestObject(“Object Repository/button_Launchpad_Facility Monitoring”))
2019-07-04 14:51:14.953 DEBUG t.FMS_Status_Event Report_ExportToCSV - 7: delay(5)
2019-07-04 14:51:19.977 DEBUG t.FMS_Status_Event Report_ExportToCSV - 8: EventReport = findWebElement(findTestObject(“Object Repository/a_FMS_Status_Event Report”), 30)
2019-07-04 14:51:20.007 DEBUG t.FMS_Status_Event Report_ExportToCSV - 9: executeJavaScript(“arguments[0].click()”, Arrays.asList(EventReport))
2019-07-04 14:51:20.036 DEBUG t.FMS_Status_Event Report_ExportToCSV - 10: delay(5)
2019-07-04 14:51:25.038 DEBUG t.FMS_Status_Event Report_ExportToCSV - 11: ExportEventReport = findWebElement(findTestObject(“Object Repository/button_FMS_Status_Event Report_Export to CSV”), 30)
2019-07-04 14:51:25.055 DEBUG t.FMS_Status_Event Report_ExportToCSV - 12: executeJavaScript(“arguments[0].click()”, Arrays.asList(ExportEventReport))
2019-07-04 14:51:25.071 DEBUG t.FMS_Status_Event Report_ExportToCSV - 13: delay(5)
2019-07-04 14:51:30.073 DEBUG t.FMS_Status_Event Report_ExportToCSV - 14: closeBrowser()
2019-07-04 14:51:30.668 INFO c.k.katalon.core.main.TestCaseExecutor - END Test Cases/Asana Task/Download PDF and Export Functions/FMS_Status_Event Report_ExportToCSV

By the way, I’m using javascript to click the button because I’m getting below error when using the WebUi.click:

Element is not clickable at point (x,x). Other element would receive the click

Hi,
Try this

Still not clicking the button. I tried it on Firefox and Chrome.