typehandling.GroovyCastException: Cannot cast object

Hi. I’m tyring to achieve something in my test case when I get this error after running.

org.codehaus.groovy.runtime.typehandling.GroovyCastException: Cannot cast object ‘[[[[CChromeDriver: chrome on WINDOWS (310d6e2294f2491c78023318a7baa142)] → xpath: //div[@class=‘racing-events-wrapper’]]] → xpath: //div[@class=‘race-events-pill’]]’ with class ‘org.openqa.selenium.support.events.EventFiringWebDriver$EventFiringWebElement’ to class ‘java.util.List’

Below is the portion of my source code.

WebDriver driver = DriverFactory.getWebDriver()
WebElement Table = driver.findElement(By.xpath("//div[@class='racing-events-wrapper']"))
List<WebElement> rows_table = Table.findElement(By.xpath("//div[@class='race-events-pill']"))

Please provide any suggestion. Thank you!

At the 3rd line, you should use findElements (plural), not findElement (singular)

Thanks @kazurayam mate. How dumb of me I did not see it. Now, I can continue on my test case.