use of org.asqatasun.ruleimplementation.ElementHandlerImpl 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();
}
use of org.asqatasun.ruleimplementation.ElementHandlerImpl 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();
}
use of org.asqatasun.ruleimplementation.ElementHandlerImpl 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();
}
use of org.asqatasun.ruleimplementation.ElementHandlerImpl 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();
}
use of org.asqatasun.ruleimplementation.ElementHandlerImpl 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();
}
Aggregations