我有以下接口:列表鑄造界面是用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
投在這種情況下失敗?