Getting this error while running javascript

org.codehaus.groovy.runtime.typehandling.GroovyCastException: Cannot cast object ‘[[[CChromeDriver: chrome on MAC (84d0a371b64916993b26560cb564d909)] → xpath: //label[@id=‘file-drag’]], [[CChromeDriver: chrome on MAC (84d0a371b64916993b26560cb564d909)] → xpath: //label[@id=‘file-drag’]]]’ with class ‘java.util.ArrayList’ to class ‘com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords’ due to: groovy.lang.GroovyRuntimeException: Could not find matching constructor for: com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords(org.openqa.selenium.support.events.EventFiringWebDriver$EventFiringWebElement, org.openqa.selenium.support.events.EventFiringWebDriver$EventFiringWebElement)

My code is below

WebUI element = WebUiCommonHelper.findWebElements(findTestObject(‘label_Drag Drop a csv or an Excel file here’), 30)
WebUI.executeJavaScript(‘arguments[0].style.display=‘block’’, Arrays.asList(element))

can you please let me know what is wrong here?

findWebElements is a functions that returns a list of WebElements
you are trying to assign that list to a variable that is supposed to be WebUI, which is not a list, and not even a WebElement for that matter, WebUI is short for WebUiBuiltInKeywords, usually imported as such

Please use the Code Format syntax for better readability.

2 Likes

Quotation characters!
You should use double quotes "..." and single quotes '...' appropriately.
http://docs.groovy-lang.org/latest/html/documentation/index.html#all-strings