List of usage examples for org.openqa.selenium.support.pagefactory Annotations Annotations
public Annotations(Field field)
From source file:com.arcbees.test.ElementLocator.java
License:Apache License
private void processAnnotations(Field field) { Annotations annotations = new Annotations(field); processFindBy(field, annotations);//from ww w . j a v a2 s .c om processWaitTimeout(field); shouldCache = annotations.isLookupCached(); }
From source file:com.common.seleniumlib.CustomElementLocator.java
License:Apache License
/** * Creates a new element locator.//from ww w.ja v a 2 s. c o m * * @param searchContext The context to use when finding the element * @param field The field on the Page Object that will hold the located value */ public CustomElementLocator(SearchContext searchContext, Field field) { this(searchContext, new Annotations(field)); }
From source file:com.qmetry.qaf.automation.ui.webdriver.ElementFactory.java
License:Open Source License
@SuppressWarnings("unchecked") public void initFields(Object classObj) { Field[] flds = ClassUtil.getAllFields(classObj.getClass(), AbstractTestPage.class); for (Field field : flds) { try {// ww w. ja va2s . c om field.setAccessible(true); if (isDecoratable(field)) { Object value = null; if (hasAnnotation(field, FindBy.class, FindBys.class)) { Annotations annotations = new Annotations(field); boolean cacheElement = annotations.isLookupCached(); By by = annotations.buildBy(); if (List.class.isAssignableFrom(field.getType())) { value = initList(by, context); } else { if (context instanceof WebElement) { value = new QAFExtendedWebElement((QAFExtendedWebElement) context, by); } else { value = new QAFExtendedWebElement((QAFExtendedWebDriver) context, by, cacheElement); } initMetadata(classObj, field, (QAFExtendedWebElement) value); } } else { com.qmetry.qaf.automation.ui.annotations.FindBy findBy = field .getAnnotation(com.qmetry.qaf.automation.ui.annotations.FindBy.class); if (List.class.isAssignableFrom(field.getType())) { value = initList(field, findBy.locator(), context, classObj); } else { if (QAFWebComponent.class.isAssignableFrom(field.getType())) { value = ComponentFactory.getObject(field.getType(), findBy.locator(), classObj, context); } else { value = new QAFExtendedWebElement(findBy.locator()); if (context instanceof QAFExtendedWebElement) { ((QAFExtendedWebElement) value).parentElement = (QAFExtendedWebElement) context; } } initMetadata(classObj, field, (QAFExtendedWebElement) value); } } field.set(classObj, value); } } catch (Exception e) { logger.error(e); } } }
From source file:gov.nih.nci.firebird.commons.selenium2.support.AbstractLoadableComponent.java
License:Open Source License
/** * Asserts that an annotated WebElement field is present (or if a List, is non-empty). * * @param findByField field annotated by FindBy or FindBys *///from ww w . j a va2 s . com protected void assertFindByPresent(Field findByField) { assertPresent(new Annotations(findByField).buildBy()); }
From source file:selenium.common.pagefactory.DefaultElementLocator.java
License:Apache License
/** * Creates a new element locator./*from ww w. ja v a 2 s . co m*/ * * @param searchContext * The context to use when finding the element * @param field * The field on the Page Object that will hold the located value */ public DefaultElementLocator(SearchContext searchContext, Field field) { this.searchContext = searchContext; Annotations annotations = new Annotations(field); shouldCache = annotations.isLookupCached(); by = annotations.buildBy(); }
From source file:ui.auto.core.pagecomponent.ComponentFieldDecorator.java
License:Apache License
@Override public Object decorate(ClassLoader loader, final Field field) { String dataValue = null;/*from w w w . j a v a 2 s .co m*/ String initialValue = null; String expectedValue = null; if (PageComponent.class.isAssignableFrom(field.getType())) { ElementLocator locator = factory.createLocator(field); if (locator == null) return null; ComponentData componentData = null; try { field.setAccessible(true); componentData = (ComponentData) field.get(page); } catch (IllegalArgumentException | IllegalAccessException e) { throw new RuntimeException(e); } if (componentData != null) { dataValue = componentData.getData(DataTypes.Data, false); initialValue = componentData.getData(DataTypes.Initial, false); expectedValue = componentData.getData(DataTypes.Expected, false); } Enhancer enhancer = new Enhancer(); enhancer.setSuperclass(field.getType()); enhancer.setCallback(new ComponentMethodInterceptor(locator)); Object componentProxy = enhancer.create(); ((ComponentData) componentProxy).initializeData(dataValue, initialValue, expectedValue); Annotations annotations = new Annotations(field); ((PageComponent) componentProxy).selector = annotations.buildBy(); return componentProxy; } return super.decorate(loader, field); }
From source file:webdriver.elements.factory.UIElementLocator.java
License:Apache License
/** * Creates a new element locator.//from w w w .ja v a2 s . com * * @param searchContext The context to use when finding the element * @param field The field on the Page Object that will hold the located value */ public UIElementLocator(SearchContext searchContext, Field field) { this.searchContext = searchContext; Annotations annotations = new Annotations(field); shouldCache = annotations.isLookupCached(); by = annotations.buildBy(); // ui = annotations.buildBy(); }