private CreateBrowsersUsing getClassLevelAnnotation(Field field) { Class<?> testClass = field.getDeclaringClass(); CreateBrowsersUsing isPresent = testClass.getAnnotation(CreateBrowsersUsing.class); if (isPresent == null && testClass.isAnnotationPresent(Nested.class)) { Class<?> declaringClass = testClass.getDeclaringClass(); while (declaringClass != null && isPresent == null) { isPresent = declaringClass.getAnnotation(CreateBrowsersUsing.class); declaringClass = declaringClass.getDeclaringClass(); } } return isPresent; }