Package rife.test
Class ParsedHtml
java.lang.Object
rife.test.ParsedHtml
Retrieves the text content of a
MockResponse
and parses it as HTML.- Since:
- 1.0
-
Method Summary
Modifier and TypeMethodDescriptionRetrieves the document that corresponds to the parsed HTML.static String
getElementAttribute
(Element element, String attributeName) Retrieves the value of the attribute of an JSoup element.getForms()
Retrieves the list of all the forms in the HTML document.getFormWithId
(String id) Retrieves the first form in the HTML document with a particularid
attribute.getFormWithName
(String name) Retrieves the first form in the HTML document with a particularname
attribute.getLinks()
Retrieves the list of all the links in the HTML document.getLinkWithId
(String id) Retrieves the first link in the HTML document with a particularid
attribute.Retrieves the first link in the HTML document that surrounds animg
tag with a certainalt
attribute.getLinkWithImageName
(String name) Retrieves the first link in the HTML document that surrounds animg
tag with a certainname
attribute.getLinkWithName
(String name) Retrieves the first link in the HTML document with a particularname
attribute.getLinkWithText
(String text) Retrieves the first link in the HTML document that surrounds a particular text.getTitle()
Retrieves the text of thetitle
tag.static ParsedHtml
parse
(MockResponse response) Parses the text content of aMockResponse
object as HTML and returns the result as an instance ofParsedHtml
.
-
Method Details
-
parse
Parses the text content of aMockResponse
object as HTML and returns the result as an instance ofParsedHtml
.- Parameters:
response
- the response whose text content will be parsed- Returns:
- the resulting instance of
ParsedHtml
- Since:
- 1.0
-
getDocument
Retrieves the document that corresponds to the parsed HTML.- Returns:
- the parsed document
- Since:
- 1.0
-
getTitle
Retrieves the text of thetitle
tag.- Returns:
- the title
- Since:
- 1.0
-
getForms
Retrieves the list of all the forms in the HTML document.- Returns:
- a list with
MockForm
instances - Since:
- 1.0
- See Also:
-
getFormWithName
Retrieves the first form in the HTML document with a particularname
attribute.- Parameters:
name
- the content of thename
attribute- Returns:
- the first
MockForm
whosename
attribute matches; ornull
if no such form could be found - Since:
- 1.0
- See Also:
-
getFormWithId
Retrieves the first form in the HTML document with a particularid
attribute.- Parameters:
id
- the content of theid
attribute- Returns:
- the first
MockForm
whoseid
attribute matches; ornull
if no such form could be found - Since:
- 1.0
- See Also:
-
getLinks
Retrieves the list of all the links in the HTML document.- Returns:
- a list with
MockLink
instances - Since:
- 1.0
- See Also:
-
getLinkWithName
Retrieves the first link in the HTML document with a particularname
attribute.- Parameters:
name
- the content of thename
attribute- Returns:
- the first
MockLink
whosename
attribute matches; ornull
if no such link could be found - Since:
- 1.0
- See Also:
-
getLinkWithId
Retrieves the first link in the HTML document with a particularid
attribute.- Parameters:
id
- the content of theid
attribute- Returns:
- the first
MockLink
whoseid
attribute matches; ornull
if no such link could be found - Since:
- 1.0
- See Also:
-
getLinkWithText
Retrieves the first link in the HTML document that surrounds a particular text.- Parameters:
text
- the surrounded text- Returns:
- the first
MockLink
whose surrounded text matches; ornull
if no such link could be found - Since:
- 1.0
- See Also:
-
getLinkWithImageAlt
Retrieves the first link in the HTML document that surrounds animg
tag with a certainalt
attribute.- Parameters:
alt
- the content of thealt
attribute- Returns:
- the first
MockLink
that has animg
tag whosealt
attribute matches; ornull
if no such link could be found - Since:
- 1.0
- See Also:
-
getLinkWithImageName
Retrieves the first link in the HTML document that surrounds animg
tag with a certainname
attribute.- Parameters:
name
- the content of thename
attribute- Returns:
- the first
MockLink
that has animg
tag whosename
attribute matches; ornull
if no such link could be found - Since:
- 1.0
- See Also:
-
getElementAttribute
Retrieves the value of the attribute of an JSoup element.- Parameters:
element
- the element where the attribute should be obtained fromattributeName
- the name of the attribute- Returns:
- the value of the attribute; or
null
if no attribute could be found - Since:
- 1.0
-