org.openqa.selenium.support.pagefactory.AbstractAnnotations Java Examples

The following examples show how to use org.openqa.selenium.support.pagefactory.AbstractAnnotations. 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: FieldAnnotationsProvider.java    From bobcat with Apache License 2.0 3 votes vote down vote up
/**
 * Provides an {@link AbstractAnnotations} implementation based on provided field's annotations.
 *
 * @param field    which annotations are checked
 * @param injector to provide Bobcat-augmented annotations
 * @return <ul>
 * <li>{@link Annotations} for fields decorated with {@link org.openqa.selenium.support.FindBy}, {@link org.openqa.selenium.support.FindAll} or {@link org.openqa.selenium.support.FindBys}</li>
 * <li>{@link BobcatAnnotations} for fields decorated with {@link com.cognifide.qa.bb.qualifier.FindPageObject}</li>
 * </ul>
 * @throws IllegalArgumentException when the field is not decorated with any of the above annotations
 */
public static AbstractAnnotations create(Field field, Injector injector) {
  if (AnnotationsHelper.isFindByAnnotationPresent(field)) {
    return new Annotations(field);
  }
  if (AnnotationsHelper.isFindPageObjectAnnotationPresent(field)) {
    return new BobcatAnnotations(field, injector);
  }
  throw new IllegalArgumentException(
      "Field is not marked by any supported annotation: " + field.toGenericString());
}