protected static By createBy(Annotation[] annotations, HowToUseSelectors howToUseLocators) { if (annotations == null || annotations.length == 0) { return null; } switch (howToUseLocators) { case USE_ONE: { return getMobileBy(annotations[0], getFilledValue(annotations[0])); } case BUILD_CHAINED: { return getComplexMobileBy(annotations, ByChained.class); } case USE_ANY: { return getComplexMobileBy(annotations, ByAll.class); } default: { return null; } } }
public final By getBy() { switch (type) { case CSS_SELECTOR: return new By.ByCssSelector(query); case XPATH_SELECTOR: return new By.ByXPath(query); case ID_SELECTOR: String[] ids = StringUtils.split(query); if (ids.length == 1) return new By.ById(query); By.ById[] byIds = new By.ById[ids.length]; int i = 0; for (String id : ids) byIds[i++] = new By.ById(id); return new ByAll(byIds); } return null; }
protected By buildBysFromFindByOneOf(FindAll findBys) { FindBy[] findByArray = findBys.value(); By[] byArray = new By[findByArray.length]; for (int i = 0; i < findByArray.length; ++i) { byArray[i] = this.buildByFromFindBy(findByArray[i]); } return new ByAll(byArray); }
private List<WebElement> getAllWebElements(String... tags) { By.ByTagName[] byTagNames = getByTagNameArray(tags); if (byTagNames == null) return null; return node.findElements(new ByAll(byTagNames)); }