use of org.asqatasun.ruleimplementation.ElementHandlerImpl in project Asqatasun by Asqatasun.
the class ElementPresenceCheckerTest method testCheckDefaultDetectedUnicityFailedOverrideSolutionResult2.
/**
* Test of doCheck method, of class ElementPresenceChecker.
* @throws java.io.IOException
*/
public void testCheckDefaultDetectedUnicityFailedOverrideSolutionResult2() throws IOException {
LOGGER.debug("elementPresenceChecker-check-default-detection-unicity-failed-override-solution-result2");
Document doc = Jsoup.parse(new File("src/test/resources/presenceChecker/presence-checker-unique-1.html"), Charset.defaultCharset().displayName());
ElementHandler<Element> elementHandler = new ElementHandlerImpl();
elementHandler.addAll(doc.select(HtmlElementStore.A_ELEMENT));
initMockContext(TestSolution.NOT_APPLICABLE, null);
TestSolutionHandler testSolutionHandler = new TestSolutionHandlerImpl();
ElementPresenceChecker instance = new ElementPresenceChecker(new ImmutablePair(TestSolution.NEED_MORE_INFO, "detected"), new ImmutablePair(TestSolution.NOT_APPLICABLE, ""));
instance.check(mockSspHandler, elementHandler, testSolutionHandler);
assertEquals(TestSolution.NOT_APPLICABLE, testSolutionHandler.getTestSolution());
verifyMockContext();
}
use of org.asqatasun.ruleimplementation.ElementHandlerImpl in project Asqatasun by Asqatasun.
the class CaptchaElementSelectorTest method testSelectElementsAttrParent.
/**
* Test of selectElements method, of class CaptchaElementSelector.
*/
public void testSelectElementsAttrParent() {
LOGGER.debug("selectElementsAttrParent");
Document doc = null;
try {
doc = Jsoup.parse(new File("src/test/resources/captcha/captcha5.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();
}
use of org.asqatasun.ruleimplementation.ElementHandlerImpl in project Asqatasun by Asqatasun.
the class CaptchaElementSelectorTest method testSelectElementsAttrElement.
/**
* Test of selectElements method, of class CaptchaElementSelector.
* @throws java.io.IOException
*/
public void testSelectElementsAttrElement() throws IOException {
LOGGER.debug("selectElementsAttrElement");
Document doc = Jsoup.parse(new File("src/test/resources/captcha/captcha1.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();
}
use of org.asqatasun.ruleimplementation.ElementHandlerImpl in project Asqatasun by Asqatasun.
the class CaptchaElementSelectorTest method testNoCaptcha2.
/**
* Test of selectElements method, of class CaptchaElementSelector.
*/
public void testNoCaptcha2() {
LOGGER.debug("noCaptcha1");
Document doc = null;
try {
doc = Jsoup.parse(new File("src/test/resources/captcha/no-captcha2.html"), Charset.defaultCharset().displayName());
} catch (IOException ex) {
}
initMockContext(null, doc);
ElementHandler<Element> elementHandler = new ElementHandlerImpl();
CaptchaElementSelector instance = new CaptchaElementSelector(new SimpleElementSelector(HtmlElementStore.IMG_ELEMENT));
instance.selectElements(sspHandler, elementHandler);
assertTrue(elementHandler.isEmpty());
verifyMockContext();
}
use of org.asqatasun.ruleimplementation.ElementHandlerImpl in project Asqatasun by Asqatasun.
the class ImageElementSelectorTest method testSelectElements6_1.
/**
* Test of selectElements method, of class ImageElementSelector.
*/
public void testSelectElements6_1() {
LOGGER.debug("selectElements6-1");
Document doc = null;
try {
doc = Jsoup.parse(new File("src/test/resources/images/image-composite-1.html"), Charset.defaultCharset().displayName());
} catch (IOException ex) {
}
initMockContext(HtmlElementStore.IMG_ELEMENT, doc);
ElementHandler<Element> elementHandler = new ElementHandlerImpl();
ImageElementSelector instance = new ImageElementSelector(HtmlElementStore.IMG_ELEMENT, false, true);
instance.selectElements(sspHandler, elementHandler);
assertTrue(elementHandler.isEmpty());
verifyMockContext();
}
Aggregations