List of usage examples for org.openqa.selenium.support.pagefactory DefaultFieldDecorator DefaultFieldDecorator
public DefaultFieldDecorator(ElementLocatorFactory factory)
From source file:com.github.licanhua.test.framework.base.CustomFieldDecorator.java
License:Apache License
public CustomFieldDecorator(ElementLocatorFactory factory, Element parent) { this.factory = factory; this.parent = parent; decorator = new DefaultFieldDecorator(factory); }
From source file:com.mengge.pagefactory.AppiumFieldDecorator.java
License:Apache License
/** * @param context is an instance of {@link org.openqa.selenium.SearchContext} * It may be the instance of {@link org.openqa.selenium.WebDriver} * or {@link org.openqa.selenium.WebElement} or * {@link Widget} or some other user's * extension/implementation. * @param timeOutDuration is a desired duration of the waiting for an element presence. *//* ww w. j a va 2s. c o m*/ public AppiumFieldDecorator(SearchContext context, TimeOutDuration timeOutDuration) { this.originalDriver = WebDriverUnpackUtility.unpackWebDriverFromSearchContext(context); platform = WebDriverUnpackUtility.getPlatform(originalDriver); automation = WebDriverUnpackUtility.getAutomation(originalDriver); this.timeOutDuration = timeOutDuration; defaultElementFieldDecoracor = new DefaultFieldDecorator(new AppiumElementLocatorFactory(context, timeOutDuration, originalDriver, new DefaultElementByBuilder(platform, automation))) { @Override protected WebElement proxyForLocator(ClassLoader ignored, ElementLocator locator) { return proxyForAnElement(locator); } @Override @SuppressWarnings("unchecked") protected List<WebElement> proxyForListLocator(ClassLoader ignored, ElementLocator locator) { ElementListInterceptor elementInterceptor = new ElementListInterceptor(locator); return ProxyFactory.getEnhancedProxy(ArrayList.class, elementInterceptor); } @Override protected boolean isDecoratableList(Field field) { if (!List.class.isAssignableFrom(field.getType())) { return false; } Type genericType = field.getGenericType(); if (!(genericType instanceof ParameterizedType)) { return false; } Type listType = ((ParameterizedType) genericType).getActualTypeArguments()[0]; boolean result = false; for (Class<? extends WebElement> webElementClass : availableElementClasses) { if (!webElementClass.equals(listType)) { continue; } result = true; break; } return result; } }; widgetLocatorFactory = new AppiumElementLocatorFactory(context, timeOutDuration, originalDriver, new WidgetByBuilder(platform, automation)); }
From source file:com.qa.framework.pagefactory.mobile.AppiumFieldDecorator.java
License:Apache License
/** * Instantiates a new Appium field decorator. * * @param context the context/*from w ww. j a v a 2 s. c o m*/ * @param timeOutDuration the time out duration */ public AppiumFieldDecorator(SearchContext context, TimeOutDuration timeOutDuration) { this.originalDriver = unpackWebDriverFromSearchContext(context); platform = getPlatform(originalDriver); automation = getAutomation(originalDriver); this.timeOutDuration = timeOutDuration; defaultElementFieldDecoracor = new DefaultFieldDecorator(new AppiumElementLocatorFactory(context, timeOutDuration, originalDriver, new DefaultElementByBuilder(platform, automation))) { @Override protected WebElement proxyForLocator(ClassLoader ignored, ElementLocator locator) { return proxyForAnElement(locator); } @Override @SuppressWarnings("unchecked") protected List<WebElement> proxyForListLocator(ClassLoader ignored, ElementLocator locator) { ElementListInterceptor elementInterceptor = new ElementListInterceptor(locator, originalDriver, field); return getEnhancedProxy(ArrayList.class, elementInterceptor); } @Override protected boolean isDecoratableList(Field field) { if (!List.class.isAssignableFrom(field.getType())) { return false; } Type genericType = field.getGenericType(); if (!(genericType instanceof ParameterizedType)) { return false; } Type listType = ((ParameterizedType) genericType).getActualTypeArguments()[0]; boolean result = false; for (Class<? extends WebElement> webElementClass : availableElementClasses) { if (!webElementClass.equals(listType)) { continue; } result = true; break; } return result; } }; widgetLocatorFactory = new AppiumElementLocatorFactory(context, timeOutDuration, originalDriver, new WidgetByBuilder(platform, automation)); }