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


Java FindBy类代码示例

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


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

示例1: getFindByAnno

import org.openqa.selenium.support.FindBy; //导入依赖的package包/类
private By getFindByAnno(FindBy anno){
	log.info(anno);
	switch (anno.how()) {
	
	case CLASS_NAME:
		return new By.ByClassName(anno.using());
	case CSS:
		return new By.ByCssSelector(anno.using());
	case ID:
		return new By.ById(anno.using());
	case LINK_TEXT:
		return new By.ByLinkText(anno.using());
	case NAME:
		return new By.ByName(anno.using());
	case PARTIAL_LINK_TEXT:
		return new By.ByPartialLinkText(anno.using());
	case XPATH:
		return new By.ByXPath(anno.using());
	default :
		throw new IllegalArgumentException("Locator not Found : " + anno.how() + " : " + anno.using());
	}
}
 
开发者ID:rahulrathore44,项目名称:SeleniumCucumber,代码行数:23,代码来源:PageBase.java

示例2: isDecoratable

import org.openqa.selenium.support.FindBy; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private boolean isDecoratable(Field field) {
	if (!hasAnnotation(field, com.qmetry.qaf.automation.ui.annotations.FindBy.class, FindBy.class,
			FindBys.class)) {
		return false;
	}
	if (WebElement.class.isAssignableFrom(field.getType())) {
		return true;
	}
	if (!(List.class.isAssignableFrom(field.getType()))) {
		return false;
	}
	Type genericType = field.getGenericType();
	if (!(genericType instanceof ParameterizedType)) {
		return false;
	}
	Type listType = ((ParameterizedType) genericType).getActualTypeArguments()[0];

	return WebElement.class.isAssignableFrom((Class<?>) listType);
}
 
开发者ID:qmetry,项目名称:qaf,代码行数:21,代码来源:ElementFactory.java

示例3: findByToBy

import org.openqa.selenium.support.FindBy; //导入依赖的package包/类
public static By findByToBy(FindBy locator) {
    if (locator == null) return null;
    if (!locator.id().isEmpty())
        return By.id(locator.id());
    if (!locator.className().isEmpty())
        return By.className(locator.className());
    if (!locator.xpath().isEmpty())
        return By.xpath(locator.xpath());
    if (!locator.css().isEmpty())
        return By.cssSelector(locator.css());
    if (!locator.linkText().isEmpty())
        return By.linkText(locator.linkText());
    if (!locator.name().isEmpty())
        return By.name(locator.name());
    if (!locator.partialLinkText().isEmpty())
        return By.partialLinkText(locator.partialLinkText());
    if (!locator.tagName().isEmpty())
        return By.tagName(locator.tagName());
    return null;
}
 
开发者ID:epam,项目名称:JDI,代码行数:21,代码来源:WebAnnotationsUtil.java

示例4: findByToBy

import org.openqa.selenium.support.FindBy; //导入依赖的package包/类
public static By findByToBy(FindBy locator) {
    if (locator == null) return null;
    if (!"".equals(locator.id()))
        return By.id(locator.id());
    if (!"".equals(locator.className()))
        return By.className(locator.className());
    if (!"".equals(locator.xpath()))
        return By.xpath(locator.xpath());
    if (!"".equals(locator.css()))
        return By.cssSelector(locator.css());
    if (!"".equals(locator.linkText()))
        return By.linkText(locator.linkText());
    if (!"".equals(locator.name()))
        return By.name(locator.name());
    if (!"".equals(locator.partialLinkText()))
        return By.partialLinkText(locator.partialLinkText());
    if (!"".equals(locator.tagName()))
        return By.tagName(locator.tagName());
    return null;
}
 
开发者ID:epam,项目名称:JDI,代码行数:21,代码来源:AppiumAnnotationsUtil.java

示例5: getFindByLocator

import org.openqa.selenium.support.FindBy; //导入依赖的package包/类
public static By getFindByLocator(FindBy locator) {
    if (locator == null) return null;
    if (!"".equals(locator.id()))
        return By.id(locator.id());
    if (!"".equals(locator.className()))
        return By.className(locator.className());
    if (!"".equals(locator.xpath()))
        return By.xpath(locator.xpath());
    if (!"".equals(locator.css()))
        return By.cssSelector(locator.css());
    if (!"".equals(locator.linkText()))
        return By.linkText(locator.linkText());
    if (!"".equals(locator.name()))
        return By.name(locator.name());
    if (!"".equals(locator.partialLinkText()))
        return By.partialLinkText(locator.partialLinkText());
    if (!"".equals(locator.tagName()))
        return By.tagName(locator.tagName());
    return null;
}
 
开发者ID:ggasoftware,项目名称:gga-selenium-framework,代码行数:21,代码来源:AnnotationsUtil.java

示例6: getNewLocator

import org.openqa.selenium.support.FindBy; //导入依赖的package包/类
private static By getNewLocator(Field field) {
    try {
        By byLocator = null;
        String locatorGroup = applicationVersion;
        if (locatorGroup != null) {
            JFindBy jFindBy = field.getAnnotation(JFindBy.class);
            if (jFindBy != null && locatorGroup.equals(jFindBy.group()))
                byLocator = getFindByLocator(jFindBy);
        }
        return (byLocator != null)
                ? byLocator
                : getFindByLocator(field.getAnnotation(FindBy.class));
    } catch (Exception | AssertionError ex) {
        throw exception(format("Error in get locator for type '%s'", field.getType().getName()) +
                LineBreak + ex.getMessage());
    }
}
 
开发者ID:ggasoftware,项目名称:gga-selenium-framework,代码行数:18,代码来源:BaseElement.java

示例7: getNewLocator

import org.openqa.selenium.support.FindBy; //导入依赖的package包/类
private static By getNewLocator(Field field) {
    try {
        By byLocator = null;
        String locatorGroup = APP_VERSION;
        if (locatorGroup != null) {
            JFindBy jFindBy = field.getAnnotation(JFindBy.class);
            if (jFindBy != null && locatorGroup.equals(jFindBy.group()))
                byLocator = WebAnnotationsUtil.getFindByLocator(jFindBy);
        }
        return (byLocator != null)
                ? byLocator
                : WebAnnotationsUtil.getFindByLocator(field.getAnnotation(FindBy.class));
    } catch (Exception ex) {
        throw exception("Error in get locator for type '%s'", field.getType().getName() +
                LINE_BREAK + ex.getMessage());
    }
}
 
开发者ID:ggasoftware,项目名称:gga-selenium-framework,代码行数:18,代码来源:CascadeInit.java

示例8: ExtendedElementLocator

import org.openqa.selenium.support.FindBy; //导入依赖的package包/类
/**
 * Creates a new element locator.
 * 
 * @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 ExtendedElementLocator(SearchContext searchContext, Field field)
{
	this.searchContext = searchContext;

	if (field.isAnnotationPresent(FindBy.class))
	{
		LocalizedAnnotations annotations = new LocalizedAnnotations(field);
		this.shouldCache = annotations.isLookupCached();
		this.by = annotations.buildBy();
	}
	// Elements to be recognized by Alice
	if (field.isAnnotationPresent(FindByAI.class))
	{
		this.aiCaption = field.getAnnotation(FindByAI.class).caption();
		this.aiLabel = field.getAnnotation(FindByAI.class).label();
	}

	this.isPredicate = false;
	if (field.isAnnotationPresent(Predicate.class))
	{
		this.isPredicate = field.getAnnotation(Predicate.class).enabled();
	}
}
 
开发者ID:qaprosoft,项目名称:carina,代码行数:32,代码来源:ExtendedElementLocator.java

示例9: isDecoratableList

import org.openqa.selenium.support.FindBy; //导入依赖的package包/类
private boolean isDecoratableList(Field field, Class<?> type) {
  if (!List.class.isAssignableFrom(field.getType())) {
    return false;
  }

  Class<?> listType = getListGenericType(field);

  return listType != null && type.isAssignableFrom(listType)
    && (field.getAnnotation(FindBy.class) != null || field.getAnnotation(FindBys.class) != null);
}
 
开发者ID:codeborne,项目名称:selenide-appium,代码行数:11,代码来源:SelenideAppiumFieldDecorator.java

示例10: processLoadableContextForClass

import org.openqa.selenium.support.FindBy; //导入依赖的package包/类
private void processLoadableContextForClass(Class clazz, ConditionHierarchyNode parent,
    Object injectee) {
  List<Field> declaredFields = Arrays.asList(clazz.getDeclaredFields());
  List<Field> applicableFields = declaredFields.stream()
      .filter(f -> (f.isAnnotationPresent(Inject.class))
          || (f.isAnnotationPresent(FindBy.class) && !f.getType().equals(WebElement.class)))
      .filter(f -> f.getType().isAnnotationPresent(PageObject.class))
      .collect(Collectors.toList());

  applicableFields.forEach(field -> {
    field.setAccessible(true);
    Object subjectInstance = null;
    try {
      subjectInstance = field.get(injectee);
    } catch (IllegalArgumentException | IllegalAccessException ex) {
      LOG.error(ex.getMessage(), ex);
    }
    ConditionHierarchyNode node = addChild(parent, new ClassFieldContext(subjectInstance,
        LoadableComponentsUtil.getConditionsFormField(field)));

    String className = node.getLoadableFieldContext().getSubjectClass().getCanonicalName();
    if (node.equals(findFirstOccurrence(node))) {
      LOG.debug("Building loadable components hierarchy tree for {}", className);
      processLoadableContextForClass(field.getType(), node, subjectInstance);
    } else {
      LOG.debug("Loadable components hierarchy tree for {} has already been built, skipping.",
          className);
    }
  });
}
 
开发者ID:Cognifide,项目名称:bobcat,代码行数:31,代码来源:ConditionsExplorer.java

示例11: assertValidAnnotations

import org.openqa.selenium.support.FindBy; //导入依赖的package包/类
@Override protected void assertValidAnnotations() {
    AnnotatedElement annotatedElement = annotatedElementContainer.getAnnotated();
    AndroidFindBy androidBy = annotatedElement.getAnnotation(AndroidFindBy.class);
    AndroidFindBys androidBys = annotatedElement.getAnnotation(AndroidFindBys.class);
    checkDisallowedAnnotationPairs(androidBy, androidBys);
    AndroidFindAll androidFindAll = annotatedElement.getAnnotation(AndroidFindAll.class);
    checkDisallowedAnnotationPairs(androidBy, androidFindAll);
    checkDisallowedAnnotationPairs(androidBys, androidFindAll);

    SelendroidFindBy selendroidBy = annotatedElement.getAnnotation(SelendroidFindBy.class);
    SelendroidFindBys selendroidBys = annotatedElement.getAnnotation(SelendroidFindBys.class);
    checkDisallowedAnnotationPairs(selendroidBy, selendroidBys);
    SelendroidFindAll selendroidFindAll =
        annotatedElement.getAnnotation(SelendroidFindAll.class);
    checkDisallowedAnnotationPairs(selendroidBy, selendroidFindAll);
    checkDisallowedAnnotationPairs(selendroidBys, selendroidFindAll);

    iOSFindBy iOSBy = annotatedElement.getAnnotation(iOSFindBy.class);
    iOSFindBys iOSBys = annotatedElement.getAnnotation(iOSFindBys.class);
    checkDisallowedAnnotationPairs(iOSBy, iOSBys);
    iOSFindAll iOSFindAll = annotatedElement.getAnnotation(iOSFindAll.class);
    checkDisallowedAnnotationPairs(iOSBy, iOSFindAll);
    checkDisallowedAnnotationPairs(iOSBys, iOSFindAll);

    FindBy findBy = annotatedElement.getAnnotation(FindBy.class);
    FindBys findBys = annotatedElement.getAnnotation(FindBys.class);
    checkDisallowedAnnotationPairs(findBy, findBys);
    FindAll findAll = annotatedElement.getAnnotation(FindAll.class);
    checkDisallowedAnnotationPairs(findBy, findAll);
    checkDisallowedAnnotationPairs(findBys, findAll);
}
 
开发者ID:JoeUtt,项目名称:menggeqa,代码行数:32,代码来源:DefaultElementByBuilder.java

示例12: buildDefaultBy

import org.openqa.selenium.support.FindBy; //导入依赖的package包/类
@Override protected By buildDefaultBy() {
    AnnotatedElement annotatedElement = annotatedElementContainer.getAnnotated();
    By defaultBy = null;
    FindBy findBy = annotatedElement.getAnnotation(FindBy.class);
    if (findBy != null) {
        defaultBy = super.buildByFromFindBy(findBy);
    }

    if (defaultBy == null) {
        FindBys findBys = annotatedElement.getAnnotation(FindBys.class);
        if (findBys != null) {
            defaultBy = super.buildByFromFindBys(findBys);
        }
    }

    if (defaultBy == null) {
        FindAll findAll = annotatedElement.getAnnotation(FindAll.class);
        if (findAll != null) {
            defaultBy = super.buildBysFromFindByOneOf(findAll);
        }
    }
    return defaultBy;
}
 
开发者ID:JoeUtt,项目名称:menggeqa,代码行数:24,代码来源:DefaultElementByBuilder.java

示例13: getElemetLocator

import org.openqa.selenium.support.FindBy; //导入依赖的package包/类
protected By getElemetLocator(Object obj,String element) throws SecurityException,NoSuchFieldException {
	Class childClass = obj.getClass();
	By locator = null;
	try {
		locator = getFindByAnno(childClass.
				 getDeclaredField(element).
				 getAnnotation(FindBy.class));
	} catch (SecurityException | NoSuchFieldException e) {
		log.equals(e);
		throw e;
	}
	log.debug(locator);
	return locator;
}
 
开发者ID:rahulrathore44,项目名称:SeleniumCucumber,代码行数:15,代码来源:PageBase.java

示例14: findByToBy

import org.openqa.selenium.support.FindBy; //导入依赖的package包/类
private By findByToBy(FindBy locator) {
    if (locator == null)
        return null;
    if (!"".equals(locator.className()))
        return By.className(locator.className());
    if (!"".equals(locator.name()))
        return By.name(locator.name());
    if (!"".equals(locator.id()))
        return By.id(locator.id());
    if (!"".equals(locator.xpath()))
        return By.xpath(locator.xpath());
    return null;
}
 
开发者ID:epam,项目名称:JDI,代码行数:14,代码来源:WinCascadeInit.java

示例15: getNewLocatorFromField

import org.openqa.selenium.support.FindBy; //导入依赖的package包/类
protected By getNewLocatorFromField(Field field) {
    By byLocator = null;
    if (group == null)
        return findByToBy(field.getAnnotation(FindBy.class));
    JFindBy jFindBy = field.getAnnotation(JFindBy.class);
    if (jFindBy != null && group.equals(jFindBy.group()))
        byLocator = AppiumAnnotationsUtil.getFindByLocator(jFindBy);
    return byLocator != null
            ? byLocator
            : findByToBy(field.getAnnotation(FindBy.class));
}
 
开发者ID:epam,项目名称:JDI,代码行数:12,代码来源:AppiumCascadeInit.java


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