for (String childObjectName : childObjects) {
PageElement childObject = pageValidation.findPageElement(childObjectName);
if (childObject != null) {
if (!childObject.isPresent()) {
throw new ValidationErrorException()
.withMessage(format(OBJECT_S_IS_ABSENT_ON_PAGE, childObjectName));
}
else if (!childObject.isVisible()) {
throw new ValidationErrorException()
.withMessage(format(OBJECT_S_IS_NOT_VISIBLE_ON_PAGE, childObjectName));
}
else {
Rect childObjectArea = childObject.getArea();
if (!childObjectMatches(spec, objectArea, childObjectArea)) {
errorAreas.add(new ErrorArea(childObjectArea, childObjectName));
errorMessages.add(format("\"%s\" is outside \"%s\"", childObjectName, objectName));
}
}
}
else {
throw new ValidationErrorException()
.withMessage(format(OBJECT_WITH_NAME_S_IS_NOT_DEFINED_IN_PAGE_SPEC, childObjectName));
}
}
if (errorMessages.size() > 0 ) {
throw new ValidationErrorException(errorAreas, errorMessages).withErrorArea(new ErrorArea(objectArea, objectName));
}
}