use of org.jsoup.nodes.Element in project jsoup by jhy.
the class ElementsTest method hasClassCaseInsensitive.
@Test
public void hasClassCaseInsensitive() {
Elements els = Jsoup.parse("<p Class=One>One <p class=Two>Two <p CLASS=THREE>THREE").select("p");
Element one = els.get(0);
Element two = els.get(1);
Element thr = els.get(2);
assertTrue(one.hasClass("One"));
assertTrue(one.hasClass("ONE"));
assertTrue(two.hasClass("TWO"));
assertTrue(two.hasClass("Two"));
assertTrue(thr.hasClass("ThreE"));
assertTrue(thr.hasClass("three"));
}
use of org.jsoup.nodes.Element in project ZhihuDailyPurify by izzyleung.
the class NewsListFromZhihuObservable method getQuestions.
private static List<Question> getQuestions(Document document, String dailyTitle) {
List<Question> result = new ArrayList<>();
Elements questionElements = getQuestionElements(document);
for (Element questionElement : questionElements) {
Question question = new Question();
String questionTitle = getQuestionTitleFromQuestionElement(questionElement);
String questionUrl = getQuestionUrlFromQuestionElement(questionElement);
// Make sure that the question's title is not empty.
questionTitle = TextUtils.isEmpty(questionTitle) ? dailyTitle : questionTitle;
question.setTitle(questionTitle);
question.setUrl(questionUrl);
result.add(question);
}
return result;
}
use of org.jsoup.nodes.Element in project cucumber-jvm by cucumber.
the class HTMLFormatterTest method writes_index_html.
@Test
public void writes_index_html() throws IOException {
URL indexHtml = new URL(outputDir, "index.html");
Document document = Jsoup.parse(new File(indexHtml.getFile()), "UTF-8");
Element reportElement = document.body().getElementsByClass("cucumber-report").first();
assertEquals("", reportElement.text());
}
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();
}
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();
}
Aggregations