我有以下接口:列表铸造界面是用Java
public interface CustomWebElement extends WebElement
. . . methods
在下面的地方,当我尝试投WebElement
到CustomWebElement
一切都很好:
CustomWebElement a = (CustomWebElement) element.findElement(by); //findElement return WebElement
但电话到findElements
方法返回List<WebElement>
铸造失败:
List<CustomWebElement> a = (List<CustomWebElement>) element.findElements(by);
给我例外:
Inconvertable types; Cannot cast List<WebElement> to List<CustomWebElement>
为什么List
投在这种情况下失败?