Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
W
webmagic
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
沈俊林
webmagic
Commits
67eb632f
Commit
67eb632f
authored
Apr 15, 2015
by
yihua.huang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
test for issue #200
parent
b30ca6ce
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
0 deletions
+15
-0
HtmlTest.java
...ic-core/src/test/java/us/codecraft/webmagic/HtmlTest.java
+15
-0
No files found.
webmagic-core/src/test/java/us/codecraft/webmagic/HtmlTest.java
View file @
67eb632f
...
@@ -2,6 +2,7 @@ package us.codecraft.webmagic;
...
@@ -2,6 +2,7 @@ package us.codecraft.webmagic;
import
org.junit.Test
;
import
org.junit.Test
;
import
us.codecraft.webmagic.selector.Html
;
import
us.codecraft.webmagic.selector.Html
;
import
us.codecraft.webmagic.selector.Selectable
;
import
static
org
.
assertj
.
core
.
api
.
Assertions
.
assertThat
;
import
static
org
.
assertj
.
core
.
api
.
Assertions
.
assertThat
;
...
@@ -31,4 +32,18 @@ public class HtmlTest {
...
@@ -31,4 +32,18 @@ public class HtmlTest {
Html
html
=
new
Html
(
"aaaaaaa&b"
);
Html
html
=
new
Html
(
"aaaaaaa&b"
);
assertThat
(
html
.
regex
(
"(aaaaaaa&b)"
).
toString
()).
isEqualTo
(
"aaaaaaa&b"
);
assertThat
(
html
.
regex
(
"(aaaaaaa&b)"
).
toString
()).
isEqualTo
(
"aaaaaaa&b"
);
}
}
@Test
public
void
testAHrefExtract
(){
Html
html
=
new
Html
(
"<a data-tip=\"p$t$xxx\" href=\"/xx/xx\">xx</a>"
);
assertThat
(
html
.
links
().
all
()).
contains
(
"/xx/xx"
);
}
@Test
public
void
testNthNodesGet
(){
Html
html
=
new
Html
(
"<a data-tip=\"p$t$xxx\" href=\"/xx/xx\">xx</a>"
);
assertThat
(
html
.
xpath
(
"//a[1]/@href"
).
get
()).
isEqualTo
(
"/xx/xx"
);
Selectable
selectable
=
html
.
xpath
(
"//a[1]"
).
nodes
().
get
(
0
);
assertThat
(
selectable
.
xpath
(
"@href"
).
get
()).
isEqualTo
(
"/xx/xx"
);
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment