List of usage examples for org.jsoup.select Elements Elements
public Elements()
From source file:org.asqatasun.rules.elementselector.AreaElementSelector.java
@Override public void selectElements(SSPHandler sspHandler, ElementHandler<Element> elementHandler) { super.selectElements(sspHandler, elementHandler); if (elementHandler.isEmpty()) { return;//from w w w . j a v a2 s .c om } Elements mapElementsAssociatedWithImg = new Elements(); // for each map element, search the associated image and store the // element in a new collection for (Element map : elementHandler.get()) { if (isMapAssociatedWithImage(sspHandler, map)) { mapElementsAssociatedWithImg.add(map); } } elementHandler.clean(); // for all well-formed maps, keep all the area children and return them for (Element map : mapElementsAssociatedWithImg) { elementHandler.addAll(map.select(areaSelectionKey)); } }
From source file:org.asqatasun.rules.elementselector.CaptchaElementSelector.java
/** * /* w w w. j a va 2 s . com*/ * @param el * @return all the parents and the siblings of the element */ private Elements getSiblingsAndParents(Element el) { Elements siblingsAndParents = new Elements(); siblingsAndParents.addAll(el.siblingElements()); siblingsAndParents.addAll(el.parents()); return siblingsAndParents; }
From source file:org.asqatasun.rules.rgaa22.Rgaa22Rule03111.java
@Override protected void select(SSPHandler sspHandler) { super.select(sspHandler); if (getElements().isEmpty()) { return;/*from ww w.j av a2s.c o m*/ } Elements elementsWithUniqueId = new Elements(); // From the selected form elements, only keep the one with a unique id // on the page for (Element el : getElements().get()) { if (StringUtils.isNotEmpty(el.id().trim()) && CssLikeSelectorBuilder.getNumberOfElements(sspHandler, CssLikeSelectorBuilder.buildSelectorFromId(el.id())) == 1) { elementsWithUniqueId.add(el); } } // add the subset to the global selection getElements().clean().addAll(elementsWithUniqueId); if (elementsWithUniqueId.isEmpty()) { return; } for (Element el : elementsWithUniqueId) { String labelSelector = CssLikeSelectorBuilder.buildSelectorFromElementsAndAttributeValue(LABEL_ELEMENT, FOR_ATTR, el.id()); if (CssLikeSelectorBuilder.getNumberOfElements(sspHandler, labelSelector) == 0) { this.elementsWithoutLabel.add(el); } } }
From source file:org.asqatasun.rules.rgaa30.Rgaa30Rule050801.java
/** * //from w ww . j a v a2 s . co m * @param sspHandler * @param elementHandler * @param elementHandlerWithoutDataTableMarkup */ private void extractTableWithDataTableMarkup(ElementHandler<Element> elementHandler, ElementHandler<Element> elementHandlerWithoutDataTableMarkup) { Elements elementsWithMarkup = new Elements(); for (Element el : elementHandler.get()) { if (el.select(DATA_TABLE_MARKUP_CSS_LIKE_QUERY).size() > 0) { elementsWithMarkup.add(el); } else if (elementHandlerWithoutDataTableMarkup != null) { elementHandlerWithoutDataTableMarkup.add(el); } } elementHandler.clean().addAll(elementsWithMarkup); }
From source file:org.opens.tanaguru.rules.elementchecker.helper.RuleCheckHelper.java
/** * This methods parses all the elements retrieved from the scope, extracts * the ones where the occurrence "captcha" is found among the attribute values * and removes these elements from the initial set of elements. * //w w w . java 2s . co m * @param elements * @return */ public static Elements extractCaptchaElements(Elements elements) { Elements captchaElements = new Elements(); for (Element el : elements) { for (Attribute attr : el.attributes()) { if (StringUtils.containsIgnoreCase(attr.getValue(), CAPTCHA_KEYWORD)) { captchaElements.add(el); break; } } for (Element pel : el.parents()) { for (Attribute attr : pel.attributes()) { if (StringUtils.containsIgnoreCase(attr.getValue(), CAPTCHA_KEYWORD)) { captchaElements.add(el); break; } } } } elements.removeAll(captchaElements); return captchaElements; }
From source file:org.opens.tanaguru.rules.rgaa22.Rgaa22Rule03111.java
@Override protected void select(SSPHandler sspHandler, ElementHandler<Element> elementHandler) { ELEMENT_SELECTOR.selectElements(sspHandler, elementHandler); if (elementHandler.isEmpty()) { return;/* w w w. java2s. c o m*/ } Elements elementsWithUniqueId = new Elements(); // From the selected form elements, only keep the one with a unique id // on the page for (Element el : elementHandler.get()) { if (StringUtils.isNotEmpty(el.id().trim()) && CssLikeSelectorBuilder.getNumberOfElements(sspHandler, CssLikeSelectorBuilder.buildSelectorFromId(el.id())) == 1) { elementsWithUniqueId.add(el); } } // add the subset to the global selection elementHandler.clean().addAll(elementsWithUniqueId); if (elementsWithUniqueId.isEmpty()) { return; } for (Element el : elementsWithUniqueId) { String labelSelector = CssLikeSelectorBuilder.buildSelectorFromElementsAndAttributeValue(LABEL_ELEMENT, FOR_ATTR, el.id()); if (CssLikeSelectorBuilder.getNumberOfElements(sspHandler, labelSelector) == 0) { this.elementsWithoutLabel.add(el); } } }