Java 类org.openqa.selenium.support.FindAll 实例源码

项目:menggeqa    文件:DefaultElementByBuilder.java   
@Override protected By buildDefaultBy() {
    AnnotatedElement annotatedElement = annotatedElementContainer.getAnnotated();
    By defaultBy = null;
    FindBy findBy = annotatedElement.getAnnotation(FindBy.class);
    if (findBy != null) {
        defaultBy = super.buildByFromFindBy(findBy);
    }

    if (defaultBy == null) {
        FindBys findBys = annotatedElement.getAnnotation(FindBys.class);
        if (findBys != null) {
            defaultBy = super.buildByFromFindBys(findBys);
        }
    }

    if (defaultBy == null) {
        FindAll findAll = annotatedElement.getAnnotation(FindAll.class);
        if (findAll != null) {
            defaultBy = super.buildBysFromFindByOneOf(findAll);
        }
    }
    return defaultBy;
}
项目:menggeqa    文件:DefaultElementByBuilder.java   
@Override protected void assertValidAnnotations() {
    AnnotatedElement annotatedElement = annotatedElementContainer.getAnnotated();
    AndroidFindBy androidBy = annotatedElement.getAnnotation(AndroidFindBy.class);
    AndroidFindBys androidBys = annotatedElement.getAnnotation(AndroidFindBys.class);
    checkDisallowedAnnotationPairs(androidBy, androidBys);
    AndroidFindAll androidFindAll = annotatedElement.getAnnotation(AndroidFindAll.class);
    checkDisallowedAnnotationPairs(androidBy, androidFindAll);
    checkDisallowedAnnotationPairs(androidBys, androidFindAll);

    SelendroidFindBy selendroidBy = annotatedElement.getAnnotation(SelendroidFindBy.class);
    SelendroidFindBys selendroidBys = annotatedElement.getAnnotation(SelendroidFindBys.class);
    checkDisallowedAnnotationPairs(selendroidBy, selendroidBys);
    SelendroidFindAll selendroidFindAll =
        annotatedElement.getAnnotation(SelendroidFindAll.class);
    checkDisallowedAnnotationPairs(selendroidBy, selendroidFindAll);
    checkDisallowedAnnotationPairs(selendroidBys, selendroidFindAll);

    iOSFindBy iOSBy = annotatedElement.getAnnotation(iOSFindBy.class);
    iOSFindBys iOSBys = annotatedElement.getAnnotation(iOSFindBys.class);
    checkDisallowedAnnotationPairs(iOSBy, iOSBys);
    iOSFindAll iOSFindAll = annotatedElement.getAnnotation(iOSFindAll.class);
    checkDisallowedAnnotationPairs(iOSBy, iOSFindAll);
    checkDisallowedAnnotationPairs(iOSBys, iOSFindAll);

    FindBy findBy = annotatedElement.getAnnotation(FindBy.class);
    FindBys findBys = annotatedElement.getAnnotation(FindBys.class);
    checkDisallowedAnnotationPairs(findBy, findBys);
    FindAll findAll = annotatedElement.getAnnotation(FindAll.class);
    checkDisallowedAnnotationPairs(findBy, findAll);
    checkDisallowedAnnotationPairs(findBys, findAll);
}
项目:cinnamon    文件:WebDriverModule.java   
@Override
public void configure() {
    final FindByKeyInjectionListener findByKeyInjectionListener = new FindByKeyInjectionListener();
    bind(FindByKeyInjectionListener.class).toInstance(findByKeyInjectionListener);

    bindListener(Matchers.any(), new TypeListener() {
        @Override
        public <I> void hear(TypeLiteral<I> type, TypeEncounter<I> encounter) {
            if (hasFindByKeyAnnotation(type.getRawType())) {
                encounter.register(findByKeyInjectionListener);
            }
        }

        private boolean hasFindByKeyAnnotation(Class<?> clazz) {
            while (clazz != null) {
                for (Field field : clazz.getDeclaredFields()) {
                    if (field.isAnnotationPresent(FindByKey.class) || field.isAnnotationPresent(FindBy.class) || field
                            .isAnnotationPresent(FindAll.class)) {
                        return true;
                    }
                }
                // If this Class represents either the Object class, an interface, a primitive type, or void, then
                // null is returned.
                clazz = clazz.getSuperclass();
            }
            return false;
        }
    });
}
项目:cinnamon    文件:Annotations.java   
public By buildBy() {
    By ans = null;

    FindAll findAll = field.getAnnotation(FindAll.class);
    if (findAll != null) {
        ans = buildBysFromFindByOneOf(findAll);
    }

    FindBy findBy = field.getAnnotation(FindBy.class);
    if (ans == null && findBy != null) {
        ans = buildByFromFindBy(findBy);
    }

    FindByKey findByKey = field.getAnnotation(FindByKey.class);
    if (ans == null && findByKey != null) {
        ans = buildByFromFindByKey(findByKey);
    }

    if (ans == null) {
        ans = buildByFromDefault();
    }

    if (ans == null) {
        throw new IllegalArgumentException("Cannot determine how to locate element " + field);
    }

    return ans;
}