use of ru.sbtqa.tag.pagefactory.exceptions.NoSuchActionError in project page-factory-2 by sbtqa.
the class DefaultReflection method executeMethodByTitle.
@Override
public void executeMethodByTitle(Object context, String title, Object... param) {
List<Method> methods = getDeclaredMethods(context.getClass());
for (Method method : methods) {
if (isRequiredAction(method, title) && isArgumentsIdentical(method, param)) {
try {
method.setAccessible(true);
method.invoke(context, param);
return;
} catch (IllegalAccessException | InvocationTargetException e) {
throw new FactoryRuntimeException("Error while executing action '" + title + "' on " + method.getDeclaringClass().getSimpleName() + " . See the caused exception below", ExceptionUtils.getRootCause(e));
}
}
}
throw new NoSuchActionError("There is no '" + title + "' method with parameters ['" + Arrays.stream(param).map(s -> s.getClass().toString()).collect(Collectors.joining(", ")) + "'] on page '" + context.getClass() + "'");
}
Aggregations