Cannot cast object '[[CChromeDriver error


Can someone help me. When I execute my script for the List , I received an error Cannot cast object.

But when I made plural the findWebElements by following the instruction in this thread typehandling.GroovyCastException: Cannot cast object, It’s turned to gray. It means it is not working.

Do you have some type of parameterization in your Test Object, “Chemistry/lblReagent Reservoirs”? If you do, then I find it hard to see your List<WebElement> working as it should be in the format like below:

findTestObject('{your test object}', [('{property}') : '{value of property}'])

If you don’t (which I think is the case), then you have the click and sendKeys statements incorrect.

for (int index1 = 0; index1 < elements1.size(); index1++) {
    elements1.get(index1).click();   // use the web element of the list

Check the documentation:

The method findWebElements requires 2nd arument timeout. You missed it. Therefore your code is wrong, turned to gray.


In the screenshot you shared, I found a name ituro.Debugger.populateChemistryDay1.

Do you have any idea what it is? Is it your custom code?

Hi @grylion54 @kazurayam Problem solved. Thank you so much!!


You wanted to make sure that the “elements.get(index1)” is clickable before actually clicking it. It’ a good idea. So you used “WebUI.delay(x)”.

But delay(x) with x being a fixed time duration will make your test unnecessarily slow. You had better use WebDriverWait(driver, timeout).until(condition) to check the visibility of the target element, which would pass and continue to the next step as soon as the condition is met.

See try the following example.

import org.openqa.selenium.WebDriver
import org.openqa.selenium.WebElement

import com.kms.katalon.core.testobject.ConditionType
import com.kms.katalon.core.testobject.TestObject
import com.kms.katalon.core.webui.driver.DriverFactory
import com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords as WebUI

def waitForElementToAppearInDOM(WebDriver driver, WebElement element, int timer) {
	new WebDriverWait(driver, timer).until(ExpectedConditions.visibilityOf(element));

TestObject makeTestObject(String selector) {
	TestObject tObj = new TestObject(selector)
	tObj.addProperty("css", ConditionType.EQUALS, selector)
	return tObj
WebUI.verifyElementPresent(makeTestObject("input#txt-username"), 10)

List<WebElement> list = WebUI.findWebElements(makeTestObject("button#btn-login"), 10)
waitForElementToAppearInDOM(DriverFactory.getWebDriver(), list.get(0), 10)


Please use and modify this example so that it fits to your case.

(I learned this code from java - How to wait for a WebElement to be present within the DOM? - Stack Overflow)

thank you so much @kazurayam!! will try your suggestion.

hi @kazurayam @grylion54 I would like to ask how can I get the value the attribute using my code above.

In my other script, I successfully get the attribute’s using verifyElementAttributeValue, but I don’t know how I will write when I used Find Web Elements.

Thank you!

You can use the WebElement and the “getAttribute()” method, such as below where I try to get the value attribute.

def myAttribute = elements.getAttribute("value")

or, doing a comparison using “verifyMatch()”.

WebUI.verifyMatch(elements.getAttribute("value"), "Methane", false)

All you need to know about Selenium WebDriver is described in the Javadoc. You shou bookmark thi URL:

and find the section of org.openqa.selenium.WebElement:

hi @grylion54 it doesn’t work, the getAttribute turned to gray :frowning: did I miss something?

thanks @kazurayam I’ll check these URLs

Okay. The getAttribute() method is for a WebElement, not a List<WebElement>.

def myAttribute = elements.get(index1).getAttribute("value")