I have the following interfaces:
public interface CustomWebElement extends WebElement
. . . methods
In the following places, when I try to cast WebElement
to CustomWebElement
things are fine:
CustomWebElement a = (CustomWebElement) element.findElement(by); //findElement return WebElement
but the calls to findElements
method which returns List<WebElement>
casting is failing:
List<CustomWebElement> a = (List<CustomWebElement>) element.findElements(by);
giving me exception:
Inconvertable types; Cannot cast List<WebElement> to List<CustomWebElement>
why List
cast is failing in this case?