Description
Given the following class (We have a base screen class that is used for Android and iOS that each specify T as AndroidElement and IOSElement, respectively, where we want to retain the specific platform element type):
publicclassScreenWithLists<TextendsMobileElement> {
publicList<MobileElement> listME;
publicList<T> listT;
}and initialization with:
PageFactory.initElements(newAppiumFieldDecorator(driver),
newScreenWithLists<MobileElement>()); // Or AndroidElement or IOSElement
The "listT" field does not get initialized as it fails the isDecoratableList check in AppiumFieldDecorator's DefaultFieldDecorator implementation when checking the list's type is one of "availableElementClasses".
Environment
- appium java client build version: 6.1.0
- selenium client build version: 3.12
Details
This generic type may be able to be checked with an additional bounds check in AppiumFieldDecorator's isDecoratableList:
if ((listType instanceof TypeVariable) &&
Arrays.asList(((TypeVariable<?>) listType).getBounds())
.stream().anyMatch(item -> availableElementClasses.contains(item))) {
return true;
}
Testing
https://github.com/appium/java-client/blob/master/src/test/java/io/appium/java_client/pagefactory_tests/GenericTest.java
could update the Supplier to:
TempGenericPage<?> page = newTempGenericPage<>();
PageFactory
.initElements(newAppiumFieldDecorator(newMockWebDriver()),
page);
returnnull != page.getItems();
Related issue:
#368
Code To Reproduce Issue [ Good To Have ]
publicclassListParameterReproductionTest {
publicstaticclassScreenWithLists<T> {
publicList<MobileElement> listME;
publicList<T> listT;
}
publicstaticvoidmain(String[] args) {
SearchContextmockSearchContext = newSearchContext() {
@Overridepublic <TextendsWebElement> List<T> findElements(Byby) {
returnnull;
}
@Overridepublic <TextendsWebElement> TfindElement(Byby) {
returnnull;
}
};
ScreenWithLists<MobileElement> screen = newScreenWithLists<MobileElement>();
PageFactory.initElements(newAppiumFieldDecorator(mockSearchContext), screen);
assertNotNull(screen.listME);
assertNotNull(screen.listT);
}
}
Description
Given the following class (We have a base screen class that is used for Android and iOS that each specify T as AndroidElement and IOSElement, respectively, where we want to retain the specific platform element type):
and initialization with:
The "listT" field does not get initialized as it fails the isDecoratableList check in AppiumFieldDecorator's DefaultFieldDecorator implementation when checking the list's type is one of "availableElementClasses".
Environment
Details
This generic type may be able to be checked with an additional bounds check in AppiumFieldDecorator's isDecoratableList:
Testing
https://github.com/appium/java-client/blob/master/src/test/java/io/appium/java_client/pagefactory_tests/GenericTest.java
could update the Supplier to:
Related issue:
#368
Code To Reproduce Issue [ Good To Have ]