use of com.seleniumtests.uipage.htmlelements.select.ISelectList in project seleniumRobot by bhecquet.
the class SelectList method searchRelevantImplementation.
private static List<Class<? extends ISelectList>> searchRelevantImplementation() {
List<Class<? extends ISelectList>> selectImplementations = new ArrayList<>();
// load via SPI other Select implementations
ServiceLoader<ISelectList> selectLoader = ServiceLoader.load(ISelectList.class);
Iterator<ISelectList> selectsIterator = selectLoader.iterator();
while (selectsIterator.hasNext()) {
ISelectList selectClass = selectsIterator.next();
selectImplementations.add(selectClass.getClass());
}
if (selectImplementations.isEmpty()) {
throw new CustomSeleniumTestsException("Could not get list of Select classes");
}
return selectImplementations;
}
use of com.seleniumtests.uipage.htmlelements.select.ISelectList in project seleniumRobot by bhecquet.
the class SelectList method findElement.
@Override
protected void findElement() {
// set a default type so that use of selectImplementation can be done
selectImplementation = new StubSelect();
super.findElement(true);
// if we have a prefered implementation, use it
// search the right select list handler
implementationList = orderImplementations(getPreferedUiLibraries());
for (Class<? extends ISelectList> selectClass : implementationList) {
try {
ISelectList selectInstance = selectClass.getConstructor(WebElement.class, FrameElement.class).newInstance(getRealElementNoSearch(), frameElement);
if (selectInstance.isApplicable()) {
selectImplementation = selectInstance;
selectInstance.setDriver(getDriver());
break;
}
} catch (InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException | SecurityException e) {
logger.error(String.format("Cannot use Select implementation %s: %s", selectClass.getName(), e.getMessage()));
}
}
if (selectImplementation instanceof StubSelect) {
throw new ScenarioException("Cannot find type of select " + getRealElementNoSearch().getTagName());
}
options = selectImplementation.getOptions();
multiple = selectImplementation.isMultipleWithoutFind();
}
Aggregations