Skip to content

Commit 76d6afd

Browse files
committed
add selector test
1 parent 8649340 commit 76d6afd

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

src/test/java/im/nll/data/extractor/impl/SelectorExtractorTest.java

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,32 @@ public void testExtractHtml() throws Exception {
5959
"<th>website</th>", title);
6060
}
6161

62+
@Test
63+
public void testExtractHtmlEq() throws Exception {
64+
selectorExtractor = new SelectorExtractor("tr", 1, "html");
65+
String title = selectorExtractor.extract(html);
66+
Assert.assertEquals("<th>type</th> \n" +
67+
"<th>name</th> \n" +
68+
"<th>website</th>", title);
69+
}
70+
71+
@Test
72+
public void testExtractTextEq() throws Exception {
73+
selectorExtractor = new SelectorExtractor("tr", 1, "text");
74+
String title = selectorExtractor.extract(html);
75+
Assert.assertEquals("type name website", title);
76+
selectorExtractor = new SelectorExtractor("tr", 1);
77+
title = selectorExtractor.extract(html);
78+
Assert.assertEquals("type name website", title);
79+
}
80+
81+
@Test
82+
public void testExtractText() throws Exception {
83+
selectorExtractor = new SelectorExtractor("tr:nth-child(2).text");
84+
String title = selectorExtractor.extract(html);
85+
Assert.assertEquals("type name website", title);
86+
}
87+
6288
@Test
6389
public void testExtractList() throws Exception {
6490
selectorExtractor = new SelectorExtractor("tr:has(td)");

0 commit comments

Comments
 (0)