本文整理汇总了Java中org.openqa.selenium.support.FindBys类的典型用法代码示例。如果您正苦于以下问题:Java FindBys类的具体用法?Java FindBys怎么用?Java FindBys使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
FindBys类属于org.openqa.selenium.support包,在下文中一共展示了FindBys类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: isDecoratable
import org.openqa.selenium.support.FindBys; //导入依赖的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);
}
示例2: isDecoratableList
import org.openqa.selenium.support.FindBys; //导入依赖的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);
}
示例3: assertValidAnnotations
import org.openqa.selenium.support.FindBys; //导入依赖的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);
}
示例4: buildDefaultBy
import org.openqa.selenium.support.FindBys; //导入依赖的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;
}
示例5: getIdentificationForField
import org.openqa.selenium.support.FindBys; //导入依赖的package包/类
private Identification getIdentificationForField(Field field) {
IdentifyUsing identifyUsing = field.getAnnotation(IdentifyUsing.class);
if (identifyUsing != null) {
return Identifications.fromAnnotation(identifyUsing);
}
FindBy findBy = field.getAnnotation(FindBy.class);
if (findBy != null) {
return Identifications.fromAnnotation(findBy);
}
FindBys findBys = field.getAnnotation(FindBys.class);
if (findBys != null) {
return Identifications.fromAnnotation(findBys);
}
return null;
}
示例6: initFields
import org.openqa.selenium.support.FindBys; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public void initFields(Object classObj) {
Field[] flds = ClassUtil.getAllFields(classObj.getClass(), AbstractTestPage.class);
for (Field field : flds) {
try {
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);
}
}
}
示例7: shouldInitializeField
import org.openqa.selenium.support.FindBys; //导入依赖的package包/类
private boolean shouldInitializeField(Field field) {
return field.getAnnotation(IdentifyUsing.class) != null || field.getAnnotation(FindBy.class) != null
|| field.getAnnotation(FindBys.class) != null;
}
示例8: FindBysConverter
import org.openqa.selenium.support.FindBys; //导入依赖的package包/类
public FindBysConverter(FindBys findBys) {
this.findBys = findBys;
}
示例9: isDecoratableList
import org.openqa.selenium.support.FindBys; //导入依赖的package包/类
private boolean isDecoratableList(Field field) {
if (!List.class.isAssignableFrom(field.getType())) return false;
// Type erasure in Java isn't complete. Attempt to discover the generic type of the list.
Type genericType = field.getGenericType();
if (!(genericType instanceof ParameterizedType)) return false;
Type listType = ((ParameterizedType) genericType).getActualTypeArguments()[0];
if (!this.shouldDecorate((Class<?>) listType)) return false;
if (field.getAnnotation(FindBy.class) == null && field.getAnnotation(FindBys.class) == null)
return false;
return true;
}
示例10: fromAnnotation
import org.openqa.selenium.support.FindBys; //导入依赖的package包/类
/**
* Creates an {@link Identification identification} from the given
* {@link FindBys @FindBys} instance.
*
* @param findBys the annotation instance to use.
* @return the created identification
* @since 0.9.9
*/
public static Identification fromAnnotation(FindBys findBys) {
return new Identification(new FindBysConverter(findBys).buildBy());
}