@FindBy(".//h3") AtlasWebElement title();
@Override public Object invoke(final Object proxy, final MethodInfo methodInfo, final Configuration configuration) { final Method method = methodInfo.getMethod(); assert proxy instanceof SearchContext; assert method.isAnnotationPresent(FindBy.class); final Map<String, String> parameters = getParameters(method, methodInfo.getArgs()); final String xpath = processTemplate(method.getAnnotation(FindBy.class).value(), parameters); final SearchContext searchContext = (SearchContext) proxy; final String name = Optional.ofNullable(method.getAnnotation(Name.class)).map(Name::value) .orElse(method.getName()); final Configuration childConfiguration = configuration.child(); final Target target = new HardcodedTarget(name, searchContext.findElement(By.xpath(xpath))); return new Atlas(childConfiguration) .create(target, method.getReturnType()); } }
@Override public Object invoke(final Object proxy, final MethodInfo methodInfo, final Configuration configuration) { final Method method = methodInfo.getMethod(); assert proxy instanceof SearchContext; assert method.isAnnotationPresent(FindBy.class); final Map<String, String> parameters = getParameters(method, methodInfo.getArgs()); final String xpath = processTemplate(method.getAnnotation(FindBy.class).value(), parameters); final String name = Optional.ofNullable(method.getAnnotation(Name.class)).map(Name::value) .orElse(method.getName()); final SearchContext context = (SearchContext) proxy; final List<WebElement> originalElements = context.findElements(By.xpath(xpath)); final Type methodReturnType = ((ParameterizedType) method.getGenericReturnType()).getActualTypeArguments()[0]; final List newElements = IntStream.range(0, originalElements.size()) .mapToObj(i -> { final WebElement originalElement = originalElements.get(i); final Configuration childConfiguration = configuration.child(); final Target target = new HardcodedTarget(listElementName(name, i), originalElement); return new Atlas(childConfiguration) .create(target, (Class<?>) methodReturnType); }) .collect(toList()); return new Atlas(configuration.child()) .create(newElements, method.getReturnType()); }
@FindBy("//header[contains(@class,'Header')]") Header header();
@FindBy("//a[contains(text(), 'Or start a free trial of Enterprise Server')]") AtlasWebElement trial();
@FindBy(".//input[contains(@class,'header-search-input')]") AtlasWebElement searchInput();
@FindBy(".//ul[contains(@class, 'repo-list')]//li[contains(@class, 'repo-list-item')]") ElementsCollection<RepositoryCard> repositories();
@FindBy(SELECTOR) ChildElement childWithoutName();
@FindBy(SELECTOR) ElementsCollection<ChildElement> childList();
@FindBy(LEAF_SELECTOR) LeafElement leaf();
@FindBy(CHILD_SELECTOR) ChildElement child();
@FindBy(SELECTOR) ElementsCollection<ListElement> collection();
@FindBy(SELECTOR) AtlasWebElement block();
@Retry(timeout = 8000) @FindBy("//div") NestedElement child(); }
@Name(ELEMENT_NAME) @FindBy(SELECTOR) ElementsCollection<ChildElement> childListWithName();
@FindBy("//div[{{ value }}]") AtlasWebElement childWithName(@Param("value") String value);
@Name(ELEMENT_NAME) @FindBy(SELECTOR) ChildElement childWithName();
@FindBy("//td[{{ value }}]") ElementsCollection<AtlasWebElement> elements(@Param("value") String value); }