use of org.openqa.selenium.support.FindBy in project selenium_java by sergueik.
the class DynamicAnnotations method buildBy.
public By buildBy() {
assertValidAnnotations();
By ans = null;
FindBys findBys = field.getAnnotation(FindBys.class);
if (findBys != null) {
// building a chained locator
ans = buildByFromFindBys(findBys);
}
FindAll findAll = field.getAnnotation(FindAll.class);
if (ans == null && findAll != null) {
// building a find by one of locator
ans = buildBysFromFindByOneOf(findAll);
}
FindBy findBy = field.getAnnotation(FindBy.class);
if (ans == null && findBy != null) {
// building an ordinary locator
ans = buildByFromFindBy(findBy);
}
if (ans == null) {
// without locator annotation will build a locator based on field name
// id or name
ans = buildByFromDefault();
}
if (ans == null) {
throw new IllegalArgumentException("Cannot determine how to locate element " + field);
}
return ans;
}
use of org.openqa.selenium.support.FindBy in project java-client by appium.
the class DefaultElementByBuilder method assertValidAnnotations.
@Override
protected void assertValidAnnotations() {
AnnotatedElement annotatedElement = annotatedElementContainer.getAnnotated();
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);
}
use of org.openqa.selenium.support.FindBy in project java-client by appium.
the class DefaultElementByBuilder method buildDefaultBy.
@Override
protected By buildDefaultBy() {
AnnotatedElement annotatedElement = annotatedElementContainer.getAnnotated();
By defaultBy = null;
FindBy findBy = annotatedElement.getAnnotation(FindBy.class);
if (findBy != null) {
defaultBy = new FindBy.FindByBuilder().buildIt(findBy, (Field) annotatedElement);
}
if (defaultBy == null) {
FindBys findBys = annotatedElement.getAnnotation(FindBys.class);
if (findBys != null) {
defaultBy = new FindBys.FindByBuilder().buildIt(findBys, (Field) annotatedElement);
}
}
if (defaultBy == null) {
FindAll findAll = annotatedElement.getAnnotation(FindAll.class);
if (findAll != null) {
defaultBy = new FindAll.FindByBuilder().buildIt(findAll, (Field) annotatedElement);
}
}
return defaultBy;
}
use of org.openqa.selenium.support.FindBy in project masquerade by cuba-platform.
the class Components method getTargetFieldValue.
protected static Object getTargetFieldValue(Class clazz, Field field, By parentBy) {
String fieldName = field.getName();
Wire wire = field.getAnnotation(Wire.class);
Object fieldValue;
if (wire != null) {
if (field.getType() == SelenideElement.class) {
fieldValue = $(parentBy);
} else if (field.getType() == By.class) {
fieldValue = parentBy;
} else if (field.getType() == Logger.class) {
fieldValue = LoggerFactory.getLogger(clazz);
} else {
String[] path = wire.path();
if (path.length == 0) {
path = new String[] { fieldName };
}
By fieldBy;
if (parentBy == BODY_MARKER_BY) {
fieldBy = byPath(path);
} else {
fieldBy = byChain(parentBy, byPath(path));
}
fieldValue = wireClassBy(field.getType(), fieldBy);
}
} else {
FindBy findBy = field.getAnnotation(FindBy.class);
if (findBy != null) {
By selector = new Annotations(field).buildBy();
By fieldBy;
if (parentBy == BODY_MARKER_BY) {
fieldBy = selector;
} else {
fieldBy = byChain(parentBy, selector);
}
fieldValue = wireClassBy(field.getType(), fieldBy);
} else {
fieldValue = null;
}
}
return fieldValue;
}
use of org.openqa.selenium.support.FindBy in project selenium_java by sergueik.
the class DynamicAnnotations method assertValidAnnotations.
public void assertValidAnnotations() {
FindBys findBys = field.getAnnotation(FindBys.class);
FindAll findAll = field.getAnnotation(FindAll.class);
FindBy findBy = field.getAnnotation(FindBy.class);
if (findBys != null && findBy != null) {
throw new IllegalArgumentException("If you use a '@FindBys' annotation, " + "you must not also use a '@FindBy' annotation");
}
if (findAll != null && findBy != null) {
throw new IllegalArgumentException("If you use a '@FindAll' annotation, " + "you must not also use a '@FindBy' annotation");
}
if (findAll != null && findBys != null) {
throw new IllegalArgumentException("If you use a '@FindAll' annotation, " + "you must not also use a '@FindBys' annotation");
}
}
Aggregations