final By rootBy = FindByUtilities.getCorrectBy(field, configuration.get().getDefaultElementLocatingStrategy());
Object wrapper;
try {
wrapper = createWrapper(grapheneContext, field.getType(), WebElementUtils.findElementLazily(rootBy, localSearchContext));
} catch (Exception e) {
throw new GrapheneTestEnricherException("Can't instantiate element wrapper " + target.getClass() + "." + field.getName() + " of type " + field.getType(), e);
}
try {
setValue(field, target, wrapper);
} catch (Exception e) {
throw new GrapheneTestEnricherException("Can't set a value to the " + target.getClass() + "." + field.getName() + ".", e);
}
} else if (field.getType().isAssignableFrom(List.class)
&& isValidClass(getListType(field))) {
final SearchContext localSearchContext;
GrapheneContext grapheneContext = searchContext == null ? null : ((GrapheneProxyInstance) searchContext).getContext();
if (grapheneContext == null) {
grapheneContext = GrapheneContext.getContextFor(ReflectionHelper.getQualifier(field.getAnnotations()));
localSearchContext = grapheneContext.getWebDriver(SearchContext.class);
} else {
localSearchContext = searchContext;
}
final By rootBy = FindByUtilities.getCorrectBy(field, configuration.get().getDefaultElementLocatingStrategy());
try {
Class<?> type = getListType(field);
Object wrappers = createWrappers(grapheneContext, type, WebElementUtils.findElementsLazily(rootBy, localSearchContext));
setValue(field, target, wrappers);
} catch (Exception e) {
throw new GrapheneTestEnricherException("Can't set a value to the " + target.getClass() + "." + field.getName() + ".", e);
}
}
} catch (ClassNotFoundException e) {
throw new IllegalStateException(e.getMessage(), e);
}