类org.openqa.selenium.support.pagefactory.FieldDecorator源码实例Demo

下面列出了怎么用org.openqa.selenium.support.pagefactory.FieldDecorator的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: selenium   文件: PageFactory.java
/**
 * Similar to the other "initElements" methods, but takes an {@link FieldDecorator} which is used
 * for decorating each of the fields.
 *
 * @param decorator the decorator to use
 * @param page      The object to decorate the fields of
 */
public static void initElements(FieldDecorator decorator, Object page) {
  Class<?> proxyIn = page.getClass();
  while (proxyIn != Object.class) {
    proxyFields(decorator, page, proxyIn);
    proxyIn = proxyIn.getSuperclass();
  }
}
 
源代码2 项目: selenium   文件: PageFactory.java
private static void proxyFields(FieldDecorator decorator, Object page, Class<?> proxyIn) {
  Field[] fields = proxyIn.getDeclaredFields();
  for (Field field : fields) {
    Object value = decorator.decorate(page.getClass().getClassLoader(), field);
    if (value != null) {
      try {
        field.setAccessible(true);
        field.set(page, value);
      } catch (IllegalAccessException e) {
        throw new RuntimeException(e);
      }
    }
  }
}
 
 类所在包
 类方法
 同包方法