org.openqa.selenium.support.pagefactory.FieldDecorator Java Examples
The following examples show how to use
org.openqa.selenium.support.pagefactory.FieldDecorator.
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: PageFactory.java From selenium with Apache License 2.0 | 5 votes |
/** * 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(); } }
Example #2
Source File: PageFactory.java From selenium with Apache License 2.0 | 5 votes |
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); } } } }