org.openqa.selenium.support.FindAll Java Examples

The following examples show how to use org.openqa.selenium.support.FindAll. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DefaultElementByBuilder.java    From java-client with Apache License 2.0 6 votes vote down vote up
@Override
protected By buildDefaultBy() {
    AnnotatedElement annotatedElement = annotatedElementContainer.getAnnotated();
    By defaultBy = null;
    FindBy findBy = annotatedElement.getAnnotation(FindBy.class);
    if (findBy != null) {
        defaultBy = new FindBy.FindByBuilder().buildIt(findBy, (Field) annotatedElement);
    }

    if (defaultBy == null) {
        FindBys findBys = annotatedElement.getAnnotation(FindBys.class);
        if (findBys != null) {
            defaultBy = new FindBys.FindByBuilder().buildIt(findBys, (Field) annotatedElement);
        }
    }

    if (defaultBy == null) {
        FindAll findAll = annotatedElement.getAnnotation(FindAll.class);
        if (findAll != null) {
            defaultBy = new FindAll.FindByBuilder().buildIt(findAll, (Field) annotatedElement);
        }
    }
    return defaultBy;
}
 
Example #2
Source File: Annotations.java    From selenium with Apache License 2.0 6 votes vote down vote up
protected void assertValidAnnotations() {
  FindBys findBys = field.getAnnotation(FindBys.class);
  FindAll findAll = field.getAnnotation(FindAll.class);
  FindBy findBy = field.getAnnotation(FindBy.class);
  if (findBys != null && findBy != null) {
    throw new IllegalArgumentException("If you use a '@FindBys' annotation, " +
         "you must not also use a '@FindBy' annotation");
  }
  if (findAll != null && findBy != null) {
    throw new IllegalArgumentException("If you use a '@FindAll' annotation, " +
         "you must not also use a '@FindBy' annotation");
  }
  if (findAll != null && findBys != null) {
    throw new IllegalArgumentException("If you use a '@FindAll' annotation, " +
         "you must not also use a '@FindBys' annotation");
  }
}
 
Example #3
Source File: DefaultFieldDecorator.java    From selenium with Apache License 2.0 6 votes vote down vote up
protected boolean isDecoratableList(Field field) {
  if (!List.class.isAssignableFrom(field.getType())) {
    return false;
  }

  // Type erasure in Java isn't complete. Attempt to discover the generic
  // type of the list.
  Type genericType = field.getGenericType();
  if (!(genericType instanceof ParameterizedType)) {
    return false;
  }

  Type listType = ((ParameterizedType) genericType).getActualTypeArguments()[0];

  if (!WebElement.class.equals(listType)) {
    return false;
  }

  return field.getAnnotation(FindBy.class) != null ||
         field.getAnnotation(FindBys.class) != null ||
         field.getAnnotation(FindAll.class) != null;
}
 
Example #4
Source File: DefaultElementByBuilder.java    From java-client with Apache License 2.0 5 votes vote down vote up
@Override
protected void assertValidAnnotations() {
    AnnotatedElement annotatedElement = annotatedElementContainer.getAnnotated();
    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);
}