Java 类org.openqa.selenium.support.pagefactory.ElementLocator 实例源码

项目:cinnamon    文件:PageElementFieldDecorator.java   
@Override
public Object decorate(final ClassLoader ignored, final Field field) {
    if (!isProxyable(field)) {
        return null;
    }

    final ElementLocator locator = new PageElementLocator(webDriver, context, field);

    if (PageElement.class.isAssignableFrom(field.getType())) {
        return proxyForLocator(field, locator);
    } else if (PageElementCollection.class.isAssignableFrom(field.getType())) {
        return proxyForCollectionLocator(locator);
    } else {
        return null;
    }
}
项目:bobcat    文件:NestedSelectorScopedLocatorFactory.java   
/**
 * Returns scope represented by this factory. In this case, it is
 * {@link NestedSelectorScopedElementLocator} constructed out of parent factory and parent field
 * and selector.
 */
@Override
public ElementLocator getCurrentScope() {

  return new NestedSelectorScopedElementLocator(searchContext, parentFactory, selector,
      globalCurrenScope);
}
项目:bobcat    文件:PageObjectSelectorListProxyProvider.java   
private SearchContext acquireSearchContext(ElementLocatorFactory elementLocatorFactory) {
  SearchContext searchContext;
  ElementLocator parentElementLocator = ((ParentElementLocatorProvider) elementLocatorFactory).
    getCurrentScope();
  if (parentElementLocator instanceof SearchContextAwareLocator) {
    searchContext = ((SearchContextAwareLocator) parentElementLocator).getSearchContext();
  } else {
    searchContext = parentElementLocator.findElement();
  }
  return searchContext;
}
项目:cinnamon    文件:PageElementFieldDecorator.java   
private Object proxyForLocator(final Field field, final ElementLocator locator) {
    final PageElementInterceptor methodInterceptor = new PageElementInterceptor(locator);
    final Class<?>[] argTypes = new Class<?>[] {};
    final Object[] args = new Object[] {};
    return getEnhancedProxy(field.getType(), argTypes, args, methodInterceptor);

}
项目:wiselenium    文件:ElementDecoratorChainTemplate.java   
@Override
public Object decorate(ClassLoader loader, Field field) {
    if (field.isAnnotationPresent(Root.class)) return null;
    if (!this.shouldDecorate(field)) return this.nextDecoratorInChain.decorate(loader, field);

    ElementLocator locator = this.factory.createLocator(field);
    if (locator == null) return null;
    return this.decorateField(loader, field, locator);
}
项目:wiselenium    文件:ElementDecoratorChainTemplate.java   
private Object decorateField(ClassLoader loader, Field field, ElementLocator locator) {
    if (this.isDecoratableList(field)) {
        List<WebElement> webElements = this.proxyForListLocator(loader, locator);
        Class<?> listType = (Class<?>) ((ParameterizedType) field.getGenericType())
                .getActualTypeArguments()[0];
        return this.decorate(listType, webElements);
    }
    WebElement webElement = this.proxyForLocator(loader, locator);
    return this.decorate(field.getType(), webElement);
}
项目:carina    文件:LocatingElementListHandler.java   
public LocatingElementListHandler(ElementLocator locator, String name, By by, WebDriver driver)
{
    this.locator = locator;
    this.name = name;
    this.by = by;
    this.webDriver = driver;
}
项目:carina    文件:AbstractUIObjectListHandler.java   
public AbstractUIObjectListHandler(Class<?> clazz, WebDriver webDriver, ElementLocator locator, String name)
{
    this.clazz = clazz;
    this.webDriver = webDriver;
    this.locator = locator;
    this.name = name;
}
项目:carina    文件:ExtendedFieldDecorator.java   
protected ExtendedWebElement proxyForLocator(ClassLoader loader, Field field, ElementLocator locator)
{
    InvocationHandler handler = new LocatingElementHandler(locator);
    WebElement proxy = (WebElement) Proxy.newProxyInstance(loader, new Class[]
    { WebElement.class, WrapsElement.class, Locatable.class }, handler);
    return new ExtendedWebElement(proxy, field.getName(), field.isAnnotationPresent(FindBy.class) ? new LocalizedAnnotations(field).buildBy() : null, webDriver);
}
项目:carina    文件:ExtendedFieldDecorator.java   
@SuppressWarnings("unchecked")
protected List<ExtendedWebElement> proxyForListLocator(ClassLoader loader, Field field, ElementLocator locator)
{
    InvocationHandler handler = new LocatingElementListHandler(locator, field.getName(), new LocalizedAnnotations(field).buildBy(), webDriver);
    List<ExtendedWebElement> proxies = (List<ExtendedWebElement>) Proxy.newProxyInstance(loader, new Class[]
    { List.class }, handler);

    return proxies;
}
项目:carina    文件:ExtendedFieldDecorator.java   
@SuppressWarnings("unchecked")
protected <T extends AbstractUIObject> List<T> proxyForListUIObjects(ClassLoader loader, Field field,
        ElementLocator locator)
{
    InvocationHandler handler = new AbstractUIObjectListHandler<T>((Class<?>) getListType(field), webDriver,
            locator, field.getName());
    List<T> proxies = (List<T>) Proxy.newProxyInstance(loader, new Class[]
    { List.class }, handler);
    return proxies;
}
项目:bobcat    文件:WebElementScopedLocatorFactory.java   
/**
 * Returns scope represented by this locator factory.
 */
@Override
public ElementLocator getCurrentScope() {
  return new WebElementLocator(webElement);
}
项目:bobcat    文件:WebElementScopedLocatorFactory.java   
/**
 * Return a DefaultElementLocator.
 */
@Override
public ElementLocator createLocator(Field field) {
  return new DefaultElementLocator(resolveContext(field), field);
}
项目:bobcat    文件:SelectorScopedLocatorFactory.java   
/**
 * Creates a locator for the given field.
 */
@Override
public ElementLocator createLocator(Field field) {
  return new SelectorScopedElementLocator(searchContext, selector, field);
}
项目:bobcat    文件:SelectorScopedLocatorFactory.java   
/**
 * Returns scope represented by this factory.
 * In this case, it is SelectorElementLocator constructed out of searchContext and selector.
 */
@Override
public ElementLocator getCurrentScope() {
  return new SelectorElementLocator(searchContext, selector);
}
项目:bobcat    文件:NestedSelectorScopedLocatorFactory.java   
/**
 * Creates a locator for the given field.
 */
@Override
public ElementLocator createLocator(Field field) {
  return field.isAnnotationPresent(Global.class) ? new DefaultElementLocator(searchContext, field)
      : new SelectorScopedElementLocator(searchContext, selector, field);
}
项目:bobcat    文件:ScopedElementLocatorFactory.java   
@Override
public ElementLocator getCurrentScope() {
  return parentFactory.createLocator(parentField);
}
项目:bobcat    文件:ScopedElementLocatorFactory.java   
@Override
public ElementLocator createLocator(final Field field) {
  return field.isAnnotationPresent(Global.class) ?
      new DefaultElementLocator(webDriver, field) :
      new ScopedElementLocator(parentFactory, parentField, field);
}
项目:bobcat    文件:CurrentWebElementProviderTest.java   
@Override
public ElementLocator createLocator(Field field) {
  return null;
}
项目:bobcat    文件:CurrentWebElementProviderTest.java   
@Override
public ElementLocator createLocator(Field field) {
  return null;
}
项目:bobcat    文件:CurrentWebElementProviderTest.java   
@Override
public ElementLocator getCurrentScope() {
  return null;
}
项目:jpagefactory    文件:JPageFactoryElementLocatorFactory.java   
public ElementLocator createLocator(Field field) {
    return new JPageFactoryElementLocator(searchContext, new JPageFactoryAnnotations(field, channel));
}
项目:menggeqa    文件:AppiumFieldDecorator.java   
private WebElement proxyForAnElement(ElementLocator locator) {
    ElementInterceptor elementInterceptor = new ElementInterceptor(locator, originalDriver);
    return (WebElement) ProxyFactory.getEnhancedProxy(getTypeForProxy(), elementInterceptor);
}
项目:menggeqa    文件:ElementInterceptor.java   
ElementInterceptor(ElementLocator locator, WebDriver driver) {
    super(locator, driver);
}
项目:menggeqa    文件:InterceptorOfASingleElement.java   
public InterceptorOfASingleElement(ElementLocator locator, WebDriver driver) {
    this.locator = locator;
    this.driver = driver;
}
项目:menggeqa    文件:InterceptorOfAListOfElements.java   
public InterceptorOfAListOfElements(ElementLocator locator) {
    this.locator = locator;
}
项目:menggeqa    文件:ElementListInterceptor.java   
ElementListInterceptor(ElementLocator locator) {
    super(locator);
}
项目:WebAuto    文件:PageElementLocator.java   
@Override
public ElementLocator createLocator(Field field) {
    return new DefaultElementLocator(context, field);
}
项目:cinnamon    文件:ElementCache.java   
public ElementCache(final ElementLocator locator, WebElement element) {
    this.elementLocator = locator;
    setElement(element);
}
项目:cinnamon    文件:PageElementImpl.java   
public PageElementImpl(final WebDriver webDriver, final ElementLocator elementLocator, final WebElement element) {
    super(webDriver, elementLocator, element);
}
项目:cinnamon    文件:PageElementImpl.java   
public PageElement parent() {
    ElementLocator parentLocator = new PageElementLocator(elementLocator.getWebDriver(), By.xpath(".."));
    return PageElement.makeElement(parentLocator, parentLocator.findElement());
}
项目:cinnamon    文件:PageElementImpl.java   
@Override
public PageElement element(final By by) {
    ElementLocator childLocator = new PageElementLocator(elementLocator.getWebDriver(), getWrappedElement(), by);
    return PageElement.makeElement(childLocator, childLocator.findElement());
}
项目:cinnamon    文件:PageElementImpl.java   
@Override
public PageElementCollection all(final By by) {
    final ElementLocator childLocator = new PageElementLocator(elementLocator.getWebDriver(), getWrappedElement(), by);
    return makeCollection(childLocator, childLocator.findElements());
}
项目:cinnamon    文件:PageElementImpl.java   
@Override
public PageElement waitUntil(final Condition<WebElement> condition, Timeout timeout) {
    final ElementLocator filterLocator = new PageElementLocator(elementLocator.getWebDriver(), elementLocator.getSearchContext(),
            elementLocator.getBy(), elementLocator.getCondition().and(condition), timeout);
    return PageElement.makeElement(filterLocator, filterLocator.findElement());
}
项目:cinnamon    文件:WebElementWrapper.java   
public WebElementWrapper(final WebDriver webDriver, final ElementLocator elementLocator, final WebElement element) {
    this.elementLocator = elementLocator;
    this.cache = new ElementCache(elementLocator, element);
    this.actions = ActionsFactory.create(webDriver);
}
项目:cinnamon    文件:PageElement.java   
static PageElement makeElement(final ElementLocator elementLocator, final WebElement element) {
    final PageElement pageElement = new PageElementImpl(elementLocator.getWebDriver(), elementLocator, element);
    final Table tableElement = new TableElementImpl(elementLocator, element);
    return new PageElementFacade(pageElement, tableElement);
}
项目:cinnamon    文件:TableElementImpl.java   
public TableElementImpl(final ElementLocator elementLocator, final WebElement element) {
    this.cache = new ElementCache(elementLocator, element);
}
项目:cinnamon    文件:PageElementCollectionInterceptor.java   
PageElementCollectionInterceptor(final ElementLocator locator) {
    this.locator = locator;
}
项目:cinnamon    文件:PageElementFieldDecorator.java   
private Object proxyForCollectionLocator(final ElementLocator locator) {
    final PageElementCollectionInterceptor methodInterceptor = new PageElementCollectionInterceptor(locator);
    final Class<?>[] argTypes = new Class<?>[] { ElementLocator.class, List.class };
    final Object[] args = new Object[] { null, null };
    return getEnhancedProxy(PageElementCollection.class, argTypes, args, methodInterceptor);
}
项目:cinnamon    文件:PageElementInterceptor.java   
PageElementInterceptor(final ElementLocator locator) {
    this.locator = locator;
}