当前位置: 首页>>代码示例>>Java>>正文


Java ElementLocatorFactory类代码示例

本文整理汇总了Java中org.openqa.selenium.support.pagefactory.ElementLocatorFactory的典型用法代码示例。如果您正苦于以下问题:Java ElementLocatorFactory类的具体用法?Java ElementLocatorFactory怎么用?Java ElementLocatorFactory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ElementLocatorFactory类属于org.openqa.selenium.support.pagefactory包,在下文中一共展示了ElementLocatorFactory类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: provideValue

import org.openqa.selenium.support.pagefactory.ElementLocatorFactory; //导入依赖的package包/类
/**
 * This method produces value for the field. It constructs the context for the creation out of
 * paren't context and the field's own frame info.
 */
@Override
public Optional<Object> provideValue(Object pageObject, Field field, PageObjectContext context) {
  By selector = PageObjectProviderHelper.getSelectorFromPageObject(field);
  ElementLocatorFactory elementLocatorFactory =
      new NestedSelectorScopedLocatorFactory(webDriver, selector,
          context.getElementLocatorFactory(), AnnotationsHelper.isGlobal(field));
  final FramePath framePath = frameMap.get(pageObject);
  contextStack.push(new PageObjectContext(elementLocatorFactory, framePath));
  Object scopedPageObject = null;
  try {
    scopedPageObject = injector.getInstance(field.getType());
  } catch (Exception e) {
    if (e instanceof ConfigurationException) {
      ConfigurationException ce = (ConfigurationException) e;
      throw new BobcatRuntimeException(
          "Configuration exception: " + ce.getErrorMessages().toString(), e);
    }
    throw new BobcatRuntimeException(e.getMessage(), e);
  } finally {
    contextStack.pop();
  }
  return Optional.ofNullable(scopedPageObject);
}
 
开发者ID:Cognifide,项目名称:bobcat,代码行数:28,代码来源:SelectorPageObjectProvider.java

示例2: provideValue

import org.openqa.selenium.support.pagefactory.ElementLocatorFactory; //导入依赖的package包/类
/**
 * This method produces value for the field. It constructs the context for the creation out of
 * parent's context and the field's own frame info.
 */
@Override
public Optional<Object> provideValue(Object pageObject, Field field, PageObjectContext context) {
  final ElementLocatorFactory elementLocatorFactory = new ScopedElementLocatorFactory(webDriver,
      context.getElementLocatorFactory(), field);
  final FramePath framePath = frameMap.get(pageObject);
  contextStack.push(new PageObjectContext(elementLocatorFactory, framePath));
  Object scopedPageObject = null;
  try {
    scopedPageObject = injector.getInstance(field.getType());
  } catch (Exception e) {
    if (e instanceof ConfigurationException) {
      ConfigurationException ce = (ConfigurationException) e;
      throw new BobcatRuntimeException(
          "Configuration exception: " + ce.getErrorMessages().toString(), e);
    }
    throw new BobcatRuntimeException(e.getMessage(), e);
  } finally {
    contextStack.pop();
  }
  return Optional.ofNullable(scopedPageObject);
}
 
开发者ID:Cognifide,项目名称:bobcat,代码行数:26,代码来源:ScopedPageObjectProvider.java

示例3: inject

import org.openqa.selenium.support.pagefactory.ElementLocatorFactory; //导入依赖的package包/类
/**
 * This method creates the object of type clazz within context defined by the top web element and the
 * frame path provided as the parameter.
 *
 * @param clazz     PageObject class.
 * @param framePath instance of FramePath.
 * @param <T>       type of PageObject class that will be returned.
 * @return instance of Injector.
 */
public <T> T inject(Class<T> clazz, FramePath framePath) {
  final ElementLocatorFactory elementLocatorFactory = new DefaultElementLocatorFactory(webDriver);
  stack.push(new PageObjectContext(elementLocatorFactory, framePath));
  try {
    return injector.getInstance(clazz);
  } finally {
    stack.pop();
  }
}
 
开发者ID:Cognifide,项目名称:bobcat,代码行数:19,代码来源:PageObjectInjector.java

示例4: retrieveListFromFactory

import org.openqa.selenium.support.pagefactory.ElementLocatorFactory; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private List<WebElement> retrieveListFromFactory(ElementLocatorFactory factory) {
  InvocationHandler handler = new LocatingElementListHandler(
      ((ScopedElementLocatorFactory) factory).getCurrentScope());
  return (List<WebElement>) Proxy
      .newProxyInstance(WebElement.class.getClassLoader(), new Class[] {List.class}, handler);
}
 
开发者ID:Cognifide,项目名称:bobcat,代码行数:8,代码来源:CurrentScopeListProvider.java

示例5: NestedSelectorScopedLocatorFactory

import org.openqa.selenium.support.pagefactory.ElementLocatorFactory; //导入依赖的package包/类
/**
 * Creates a selector-scoped locator factory with scope within parent scope.
 *
 * @param searchContext Initial search context
 * @param selector Scope of the created locator
 * @param parentFactory Factory that represents scope for elements
 */
public NestedSelectorScopedLocatorFactory(SearchContext searchContext, By selector,
    ElementLocatorFactory parentFactory, boolean globalCurrenScope) {
  this.searchContext = searchContext;
  this.selector = selector;
  this.parentFactory = parentFactory;
  this.globalCurrenScope = globalCurrenScope;
}
 
开发者ID:Cognifide,项目名称:bobcat,代码行数:15,代码来源:NestedSelectorScopedLocatorFactory.java

示例6: getSearchContext

import org.openqa.selenium.support.pagefactory.ElementLocatorFactory; //导入依赖的package包/类
private SearchContext getSearchContext(PageObjectContext context, Field field) {
  SearchContext searchContext = webDriver;
  ElementLocatorFactory elementLocatorFactory = context.getElementLocatorFactory();
  if (elementLocatorFactory instanceof ParentElementLocatorProvider
    && !AnnotationsHelper.isGlobal(field)) {
    searchContext = acquireSearchContext(elementLocatorFactory);
  }
  return searchContext;
}
 
开发者ID:Cognifide,项目名称:bobcat,代码行数:10,代码来源:PageObjectSelectorListProxyProvider.java

示例7: acquireSearchContext

import org.openqa.selenium.support.pagefactory.ElementLocatorFactory; //导入依赖的package包/类
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;
}
 
开发者ID:Cognifide,项目名称:bobcat,代码行数:12,代码来源:PageObjectSelectorListProxyProvider.java

示例8: shouldReturnEmptyListWhenFactoryInStackIsNotScoped

import org.openqa.selenium.support.pagefactory.ElementLocatorFactory; //导入依赖的package包/类
@Test
public void shouldReturnEmptyListWhenFactoryInStackIsNotScoped() {
  //given
  ElementLocatorFactory elementLocatorFactory = mock(ElementLocatorFactory.class);
  when(contextStack.peek()).thenReturn(pageObjectContext);
  when(contextStack.peek().getElementLocatorFactory()).thenReturn(elementLocatorFactory);

  //when
  List<WebElement> actual = testedObject.get();

  //then
  assertThat(actual).isEmpty();
}
 
开发者ID:Cognifide,项目名称:bobcat,代码行数:14,代码来源:CurrentScopeListProviderTest.java

示例9: getFieldBySelector

import org.openqa.selenium.support.pagefactory.ElementLocatorFactory; //导入依赖的package包/类
/**
 * Searches for the field of a given type, identified by the selector class.
 *
 * @param selector        Locator by which to locate the dialog field.
 * @param dialogFieldType Class that represents dialog field.
 * @param <T> dialog field class
 * @return A dialogFieldType's instance that represents dialog field.
 */
public <T> T getFieldBySelector(By selector, Class<T> dialogFieldType) {
  ElementLocatorFactory fieldScope = new SelectorScopedLocatorFactory(webDriver, selector);
  elementLocatorStack.push(new PageObjectContext(fieldScope, FramePath.parsePath("$cq")));
  try {
    return injector.getInstance(dialogFieldType);
  } finally {
    elementLocatorStack.pop();
  }
}
 
开发者ID:Cognifide,项目名称:bobcat,代码行数:18,代码来源:AemDialogFieldResolver.java

示例10: WiseDecorator

import org.openqa.selenium.support.pagefactory.ElementLocatorFactory; //导入依赖的package包/类
/**
 * Constructor.
 * 
 * @param factory The factory of the elements locator.
 */
public WiseDecorator(ElementLocatorFactory factory) {
	ElementDecoratorChain wiseComponentDecorator = new WiseComponentDecorator(factory);
	ElementDecoratorChain wiseFrameDecorator = new WiseFrameDecorator(factory);
	ElementDecoratorChain webElementDecorator = new WebElementDecorator(factory);
	ElementDecoratorChain nullDecorator = new NullDecorator(factory);
	
	wiseComponentDecorator.setNext(wiseFrameDecorator);
	wiseFrameDecorator.setNext(webElementDecorator);
	webElementDecorator.setNext(nullDecorator);
	
	this.elementDecorator = wiseComponentDecorator;
}
 
开发者ID:wiselenium,项目名称:wiselenium,代码行数:18,代码来源:WiseDecorator.java

示例11: getInstance

import org.openqa.selenium.support.pagefactory.ElementLocatorFactory; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public static <E> List<E> getInstance(Class<E> clazz, List<WebElement> webElements,
		ElementLocatorFactory factory) {
	Enhancer e = new Enhancer();
	e.setInterfaces(new Class[] { List.class });
	e.setCallback(new WiseElementListProxy<E>(clazz, webElements, factory));
	return (List<E>) e.create();
}
 
开发者ID:wiselenium,项目名称:wiselenium,代码行数:9,代码来源:WiseElementListProxy.java

示例12: getElementLocatorFactory

import org.openqa.selenium.support.pagefactory.ElementLocatorFactory; //导入依赖的package包/类
/**
 * @return Element locator factory that is stored in the context.
 */
public ElementLocatorFactory getElementLocatorFactory() {
  return elementLocatorFactory;
}
 
开发者ID:Cognifide,项目名称:bobcat,代码行数:7,代码来源:PageObjectContext.java

示例13: getScopedList

import org.openqa.selenium.support.pagefactory.ElementLocatorFactory; //导入依赖的package包/类
private List<WebElement> getScopedList() {
  ElementLocatorFactory factory = stack.peek().getElementLocatorFactory();
  return factory instanceof ScopedElementLocatorFactory ?
      retrieveListFromFactory(factory) :
      Collections.emptyList();
}
 
开发者ID:Cognifide,项目名称:bobcat,代码行数:7,代码来源:CurrentScopeListProvider.java

示例14: getScopedWebElement

import org.openqa.selenium.support.pagefactory.ElementLocatorFactory; //导入依赖的package包/类
private WebElement getScopedWebElement() {
  ElementLocatorFactory factory = stack.peek().getElementLocatorFactory();
  return (factory instanceof ParentElementLocatorProvider) ?
      getWebElementFromFactory(factory) :
      getTopElement();
}
 
开发者ID:Cognifide,项目名称:bobcat,代码行数:7,代码来源:CurrentWebElementProvider.java

示例15: getWebElementFromFactory

import org.openqa.selenium.support.pagefactory.ElementLocatorFactory; //导入依赖的package包/类
private WebElement getWebElementFromFactory(ElementLocatorFactory factory) {
  InvocationHandler handler = new LocatingElementHandler(
      ((ParentElementLocatorProvider) factory).getCurrentScope());
  return (WebElement) Proxy.newProxyInstance(WebElement.class.getClassLoader(),
      new Class[] {WebElement.class, WrapsElement.class, Locatable.class}, handler);
}
 
开发者ID:Cognifide,项目名称:bobcat,代码行数:7,代码来源:CurrentWebElementProvider.java


注:本文中的org.openqa.selenium.support.pagefactory.ElementLocatorFactory类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。