Search in sources :

Example 36 with Element

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

the class TextOnlyContainsNonAlphanumericalCharactersCheckerTest method setUp.

@Override
protected void setUp() throws Exception {
    super.setUp();
    mockTextElementBuilder = createMock(TextElementBuilder.class);
    mockSSPHandler = createMock(SSPHandler.class);
    elements = new Elements();
    element = new Element(Tag.valueOf("div"), "");
    mockTestSolutionHandler = createMock(TestSolutionHandler.class);
    mockProcessRemarkService = createMock(ProcessRemarkService.class);
}
Also used : TextElementBuilder(org.asqatasun.rules.textbuilder.TextElementBuilder) Element(org.jsoup.nodes.Element) SSPHandler(org.asqatasun.processor.SSPHandler) TestSolutionHandler(org.asqatasun.ruleimplementation.TestSolutionHandler) Elements(org.jsoup.select.Elements) ProcessRemarkService(org.asqatasun.service.ProcessRemarkService)

Example 37 with Element

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

the class CaptchaElementSelectorTest method testSelectElementsTextSibling2.

/**
     * Test of selectElements method, of class CaptchaElementSelector.
     * @throws java.io.IOException
     */
public void testSelectElementsTextSibling2() throws IOException {
    LOGGER.debug("selectElementsTextSibling2");
    Document doc = Jsoup.parse(new File("src/test/resources/captcha/captcha3.html"), Charset.defaultCharset().displayName());
    initMockContext(doc);
    ElementHandler<Element> elementHandler = new ElementHandlerImpl();
    elementHandler.addAll(doc.select(HtmlElementStore.IMG_ELEMENT));
    CaptchaElementSelector instance = new CaptchaElementSelector(elementHandler);
    instance.selectElements(sspHandler, elementHandler);
    assertTrue(elementHandler.get().size() == 1);
    assertTrue(elementHandler.get().iterator().next().nodeName().equals(HtmlElementStore.IMG_ELEMENT));
    verifyMockContext();
}
Also used : Element(org.jsoup.nodes.Element) ElementHandlerImpl(org.asqatasun.ruleimplementation.ElementHandlerImpl) Document(org.jsoup.nodes.Document) File(java.io.File)

Example 38 with Element

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

the class CaptchaElementSelectorTest method testSelectElementsTextParent.

/**
     * Test of selectElements method, of class CaptchaElementSelector.
     */
public void testSelectElementsTextParent() {
    LOGGER.debug("selectElementsTextParent");
    Document doc = null;
    try {
        doc = Jsoup.parse(new File("src/test/resources/captcha/captcha4.html"), Charset.defaultCharset().displayName());
    } catch (IOException ex) {
    }
    initMockContext(HtmlElementStore.IMG_ELEMENT, doc);
    ElementHandler<Element> elementHandler = new ElementHandlerImpl();
    CaptchaElementSelector instance = new CaptchaElementSelector(new SimpleElementSelector(HtmlElementStore.IMG_ELEMENT));
    instance.selectElements(sspHandler, elementHandler);
    assertTrue(elementHandler.get().size() == 1);
    assertTrue(elementHandler.get().iterator().next().nodeName().equals(HtmlElementStore.IMG_ELEMENT));
    verifyMockContext();
}
Also used : Element(org.jsoup.nodes.Element) ElementHandlerImpl(org.asqatasun.ruleimplementation.ElementHandlerImpl) IOException(java.io.IOException) Document(org.jsoup.nodes.Document) File(java.io.File)

Example 39 with Element

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

the class CaptchaElementSelectorTest method testSelectElementsTextSibling1.

/**
     * Test of selectElements method, of class CaptchaElementSelector.
     * @throws java.io.IOException
     */
public void testSelectElementsTextSibling1() throws IOException {
    LOGGER.debug("selectElementsTextSibling1");
    Document doc = Jsoup.parse(new File("src/test/resources/captcha/captcha2.html"), Charset.defaultCharset().displayName());
    initMockContext(doc);
    ElementHandler<Element> elementHandler = new ElementHandlerImpl();
    elementHandler.addAll(doc.select(HtmlElementStore.IMG_ELEMENT));
    CaptchaElementSelector instance = new CaptchaElementSelector(elementHandler);
    instance.selectElements(sspHandler, elementHandler);
    assertTrue(elementHandler.get().size() == 1);
    assertTrue(elementHandler.get().iterator().next().nodeName().equals(HtmlElementStore.IMG_ELEMENT));
    verifyMockContext();
}
Also used : Element(org.jsoup.nodes.Element) ElementHandlerImpl(org.asqatasun.ruleimplementation.ElementHandlerImpl) Document(org.jsoup.nodes.Document) File(java.io.File)

Example 40 with Element

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

the class CaptchaElementSelectorTest method testEmptyPreSelection.

/**
     * Test of selectElements method, of class CaptchaElementSelector.
     */
public void testEmptyPreSelection() {
    LOGGER.debug("EmptyPreSelection");
    Document doc = null;
    try {
        doc = Jsoup.parse(new File("src/test/resources/captcha/captcha1.html"), Charset.defaultCharset().displayName());
    } catch (IOException ex) {
    }
    initMockContext(null, doc);
    ElementHandler<Element> elementHandler = new ElementHandlerImpl();
    CaptchaElementSelector instance = new CaptchaElementSelector(elementHandler);
    instance.selectElements(sspHandler, elementHandler);
    assertTrue(elementHandler.isEmpty());
    verifyMockContext();
}
Also used : Element(org.jsoup.nodes.Element) ElementHandlerImpl(org.asqatasun.ruleimplementation.ElementHandlerImpl) IOException(java.io.IOException) Document(org.jsoup.nodes.Document) File(java.io.File)

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