use of org.jsoup.select.Elements in project Asqatasun by Asqatasun.
the class AttributePresenceCheckerTest method setUp.
@Override
public void setUp() {
mockSSPHandler = createMock(SSPHandler.class);
elements = new Elements();
element = new Element(Tag.valueOf("div"), "");
element.attr(AttributeStore.ALT_ATTR, "test");
mockTestSolutionHandler = createMock(TestSolutionHandler.class);
mockProcessRemarkService = createMock(ProcessRemarkService.class);
}
use of org.jsoup.select.Elements in project Asqatasun by Asqatasun.
the class Rgaa32016Rule110102 method putLabelElementHandlerIntoTheMap.
/**
* This method linked each label which have an input child on a page to its
* form in a map.
*/
private void putLabelElementHandlerIntoTheMap() {
for (Element el : labelElementHandler.get()) {
Element tmpElement = el.parent();
while (tmpElement != null && StringUtils.isNotBlank(tmpElement.tagName())) {
if (tmpElement.tagName().equals(FORM_ELEMENT)) {
if (labelFormMap.containsKey(tmpElement)) {
Elements els = el.select(FORM_ELEMENT_WITH_ID_CSS_LIKE_QUERY);
if (!els.isEmpty()) {
labelFormMap.get(tmpElement).add(el);
}
} else {
Elements els = el.select(FORM_ELEMENT_WITH_ID_CSS_LIKE_QUERY);
if (!els.isEmpty()) {
ElementHandler<Element> labelElement = new ElementHandlerImpl();
labelElement.add(el);
labelFormMap.put(tmpElement, labelElement);
}
}
break;
}
tmpElement = tmpElement.parent();
}
}
}
use of org.jsoup.select.Elements in project Asqatasun by Asqatasun.
the class Rgaa22Rule11091 method select.
@Override
protected void select(SSPHandler sspHandler) {
super.select(sspHandler);
// once tables selected, we extract the caption child element of each
// to make the control
Elements captionOnTable = new Elements();
for (Element el : getSelectionWithoutMarkerHandler().get()) {
captionOnTable.add(el.select(CAPTION_ELEMENT).first());
}
getSelectionWithoutMarkerHandler().clean().addAll(captionOnTable);
Elements captionOnDataTable = new Elements();
for (Element el : getSelectionWithMarkerHandler().get()) {
captionOnDataTable.add(el.select(CAPTION_ELEMENT).first());
}
getSelectionWithMarkerHandler().clean().addAll(captionOnDataTable);
}
use of org.jsoup.select.Elements in project Asqatasun by Asqatasun.
the class Rgaa22Rule03111 method select.
@Override
protected void select(SSPHandler sspHandler) {
super.select(sspHandler);
if (getElements().isEmpty()) {
return;
}
Elements elementsWithUniqueId = new Elements();
// 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);
}
}
}
use of org.jsoup.select.Elements in project Asqatasun by Asqatasun.
the class Aw22Rule05051 method select.
@Override
protected void select(SSPHandler sspHandler) {
super.select(sspHandler);
// once tables selected, we extract the caption child element of each
// to make the control
Elements captionOnTable = new Elements();
for (Element el : getSelectionWithoutMarkerHandler().get()) {
captionOnTable.add(el.select(CAPTION_ELEMENT).first());
}
getSelectionWithoutMarkerHandler().clean().addAll(captionOnTable);
Elements captionOnDataTable = new Elements();
for (Element el : getSelectionWithMarkerHandler().get()) {
captionOnDataTable.add(el.select(CAPTION_ELEMENT).first());
}
getSelectionWithMarkerHandler().clean().addAll(captionOnDataTable);
}
Aggregations