Search in sources :

Example 41 with Element

use of org.jsoup.nodes.Element 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);
}
Also used : Element(org.jsoup.nodes.Element) EvidenceElement(org.asqatasun.entity.audit.EvidenceElement) SSPHandler(org.asqatasun.processor.SSPHandler) TestSolutionHandler(org.asqatasun.ruleimplementation.TestSolutionHandler) Elements(org.jsoup.select.Elements) ProcessRemarkService(org.asqatasun.service.ProcessRemarkService)

Example 42 with Element

use of org.jsoup.nodes.Element in project Asqatasun by Asqatasun.

the class Rgaa30Rule090104 method select.

@Override
protected void select(SSPHandler sspHandler) {
    super.select(sspHandler);
    Iterator<Element> elementsIterator = getElements().get().iterator();
    while (elementsIterator.hasNext()) {
        Element element = elementsIterator.next();
        if (element.hasAttr("aria-level")) {
            if (!PATTERN.matcher(element.attr("aria-level")).matches()) {
                elementsIterator.remove();
            }
        }
    }
}
Also used : Element(org.jsoup.nodes.Element) EvidenceElement(org.asqatasun.entity.audit.EvidenceElement)

Example 43 with Element

use of org.jsoup.nodes.Element in project Asqatasun by Asqatasun.

the class Rgaa30Rule100701 method doSelect.

@Override
protected void doSelect(Collection<DomElement> domElements, SSPHandler sspHandler) {
    for (DomElement domElement : domElements) {
        if (domElement.isFocusable()) {
            Element el = DomElementExtractor.getElementFromDomElement(domElement, sspHandler);
            treatFocusableElement(el, domElement, getElements());
        }
    }
}
Also used : DomElement(org.asqatasun.rules.domelement.DomElement) DomElement(org.asqatasun.rules.domelement.DomElement) Element(org.jsoup.nodes.Element)

Example 44 with Element

use of org.jsoup.nodes.Element in project Asqatasun by Asqatasun.

the class Rgaa32016Rule060303 method testLink.

/**
     * 
     * @param sspHandler
     * @param el
     * @return 
     */
private TestSolution testLink(SSPHandler sspHandler, Element el) {
    ElementHandler<Element> elHandler = new ElementHandlerImpl(el);
    TestSolutionHandler tsHandler = new TestSolutionHandlerImpl();
    // reset the service for each tested element. We use the collection 
    // handled by the service to feed the local collection of remarks
    prs.resetService();
    // check the pertinence of the link
    getDecidableElementsChecker().check(sspHandler, elHandler, tsHandler);
    // get the processRemark for eventually override it with the result
    // returned by the title pertinence checker
    ProcessRemark remark = prs.getRemarkList().iterator().next();
    // to nmi but the inverse is impossible.
    if (tsHandler.getTestSolution().equals(TestSolution.FAILED)) {
        // check the pertinence of the title of the link
        String linkText = getDecidableElementsChecker().getTextElementBuilder().buildTextFromElement(el);
        if (testTitleAttributeLink(sspHandler, el, linkText).equals(TestSolution.NEED_MORE_INFO)) {
            //override result (evidence element have already been collected
            remark.setIssue(TestSolution.NEED_MORE_INFO);
            remark.setMessageCode(CHECK_LINK_PERTINENCE_MSG);
            remarks.add(remark);
            return TestSolution.NEED_MORE_INFO;
        }
    }
    remarks.add(remark);
    return tsHandler.getTestSolution();
}
Also used : Element(org.jsoup.nodes.Element) ElementHandlerImpl(org.asqatasun.ruleimplementation.ElementHandlerImpl) TestSolutionHandlerImpl(org.asqatasun.ruleimplementation.TestSolutionHandlerImpl) TestSolutionHandler(org.asqatasun.ruleimplementation.TestSolutionHandler) ProcessRemark(org.asqatasun.entity.audit.ProcessRemark)

Example 45 with Element

use of org.jsoup.nodes.Element in project Asqatasun by Asqatasun.

the class Rgaa32016Rule060303 method testTitleAttributeLink.

/**
     * 
     * @param sspHandler
     * @param el
     * @param linkText
     * @return 
     */
private TestSolution testTitleAttributeLink(SSPHandler sspHandler, Element el, String linkText) {
    // content identical to the link text, returns not applicable.
    if (!el.hasAttr(TITLE_ATTR)) {
        return TestSolution.NOT_APPLICABLE;
    }
    String attrValue = el.attr(TITLE_ATTR);
    if (StringUtils.isBlank(attrValue)) {
        return TestSolution.NOT_APPLICABLE;
    }
    if (StringUtils.equalsIgnoreCase(attrValue, linkText)) {
        return TestSolution.NOT_APPLICABLE;
    }
    ElementHandler<Element> elHandler = new ElementHandlerImpl(el);
    TestSolutionHandler tsHandler = new TestSolutionHandlerImpl();
    titlePertinenceElementChecker.check(sspHandler, elHandler, tsHandler);
    return tsHandler.getTestSolution();
}
Also used : Element(org.jsoup.nodes.Element) ElementHandlerImpl(org.asqatasun.ruleimplementation.ElementHandlerImpl) TestSolutionHandlerImpl(org.asqatasun.ruleimplementation.TestSolutionHandlerImpl) TestSolutionHandler(org.asqatasun.ruleimplementation.TestSolutionHandler)

Aggregations

Element (org.jsoup.nodes.Element)400 Document (org.jsoup.nodes.Document)164 Elements (org.jsoup.select.Elements)120 ElementHandlerImpl (org.asqatasun.ruleimplementation.ElementHandlerImpl)87 IOException (java.io.IOException)66 File (java.io.File)62 Test (org.junit.Test)62 ArrayList (java.util.ArrayList)56 Configuration (com.vaadin.addon.charts.model.Configuration)22 DesignContext (com.vaadin.ui.declarative.DesignContext)22 TestSolutionHandler (org.asqatasun.ruleimplementation.TestSolutionHandler)21 URL (java.net.URL)16 TestSolutionHandlerImpl (org.asqatasun.ruleimplementation.TestSolutionHandlerImpl)15 SimpleElementSelector (org.asqatasun.rules.elementselector.SimpleElementSelector)13 TestSolution (org.asqatasun.entity.audit.TestSolution)11 InputStream (java.io.InputStream)9 ElementSelector (org.asqatasun.rules.elementselector.ElementSelector)9 HashMap (java.util.HashMap)8 EvidenceElement (org.asqatasun.entity.audit.EvidenceElement)8 GradientColor (com.vaadin.addon.charts.model.style.GradientColor)7