com.meterware.httpunit

Interface HTMLSegment

public interface HTMLSegment

Represents the parse tree for a segment of HTML.

Author: Russell Gold

Method Summary
WebApplet[]getApplets()
Returns the applets found in the page in the order in which they appear.
String[]getElementNames()
Returns a list of HTML element names contained in this HTML section.
HTMLElement[]getElementsWithAttribute(String name, String value)
Returns the HTMLElements found with the specified attribute value.
HTMLElement[]getElementsWithName(String name)
Returns the HTMLElements found in this segment with the specified name.
HTMLElementgetElementWithID(String id)
Returns the HTMLElement found in this segment with the specified ID.
WebFormgetFirstMatchingForm(HTMLElementPredicate predicate, Object value)
Returns the first form found in the page matching the specified criteria.
WebLinkgetFirstMatchingLink(HTMLElementPredicate predicate, Object value)
Returns the first link found in the page matching the specified criteria.
WebTablegetFirstMatchingTable(HTMLElementPredicate predicate, Object criteria)
Returns the first table in the response which matches the specified predicate and value.
WebForm[]getForms()
Returns the forms found in this HTML segment in the order in which they appear.
WebFormgetFormWithID(String ID)
Returns the form found in this HTML segment with the specified ID.
WebFormgetFormWithName(String name)
Returns the form found in this HTML segment with the specified name.
WebImage[]getImages()
Returns the images found in the page in the order in which they appear.
WebImagegetImageWithAltText(String source)
Returns the first image found in the page with the specified alt attribute.
WebImagegetImageWithName(String name)
Returns the image found in the page with the specified name.
WebImagegetImageWithSource(String source)
Returns the first image found in the page with the specified src attribute.
WebLink[]getLinks()
Returns the links found in this HTML segment in the order in which they appear.
WebLinkgetLinkWith(String text)
Returns the first link which contains the specified text.
WebLinkgetLinkWithImageText(String text)
Returns the first link which contains an image with the specified text as its 'alt' attribute.
WebForm[]getMatchingForms(HTMLElementPredicate predicate, Object criteria)
Returns all forms found in the page matching the specified criteria.
WebLink[]getMatchingLinks(HTMLElementPredicate predicate, Object criteria)
Returns all links found in the page matching the specified criteria.
WebTable[]getMatchingTables(HTMLElementPredicate predicate, Object criteria)
Returns all tables found in the page matching the specified criteria.
WebTable[]getTables()
Returns the top-level tables found in this HTML segment in the order in which they appear.
WebTablegetTableStartingWith(String text)
Returns the first table in this HTML segment which has the specified text as the full text of its first non-blank row and non-blank column.
WebTablegetTableStartingWithPrefix(String text)
Returns the first table in this HTML segment which has the specified text as a prefix of the text in its first non-blank row and non-blank column.
WebTablegetTableWithID(String ID)
Returns the first table in this HTML segment which has the specified text as its ID attribute.
WebTablegetTableWithSummary(String summary)
Returns the first table in this HTML segment which has the specified text as its summary attribute.
TextBlock[]getTextBlocks()
Returns the top-level block elements found in the page in the order in which they appear.

Method Detail

getApplets

public WebApplet[] getApplets()
Returns the applets found in the page in the order in which they appear.

Throws: SAXException thrown if there is an error parsing the segment.

getElementNames

public String[] getElementNames()
Returns a list of HTML element names contained in this HTML section.

getElementsWithAttribute

public HTMLElement[] getElementsWithAttribute(String name, String value)
Returns the HTMLElements found with the specified attribute value.

Since: 1.6

getElementsWithName

public HTMLElement[] getElementsWithName(String name)
Returns the HTMLElements found in this segment with the specified name.

getElementWithID

public HTMLElement getElementWithID(String id)
Returns the HTMLElement found in this segment with the specified ID.

Throws: SAXException thrown if there is an error parsing the segment.

getFirstMatchingForm

public WebForm getFirstMatchingForm(HTMLElementPredicate predicate, Object value)
Returns the first form found in the page matching the specified criteria.

Throws: SAXException thrown if there is an error parsing the response.

getFirstMatchingLink

public WebLink getFirstMatchingLink(HTMLElementPredicate predicate, Object value)
Returns the first link found in the page matching the specified criteria.

Throws: SAXException thrown if there is an error parsing the response.

getFirstMatchingTable

public WebTable getFirstMatchingTable(HTMLElementPredicate predicate, Object criteria)
Returns the first table in the response which matches the specified predicate and value. Will recurse into any nested tables, as needed.

Returns: the selected table, or null if none is found

getForms

public WebForm[] getForms()
Returns the forms found in this HTML segment in the order in which they appear.

Throws: SAXException thrown if there is an error parsing the segment.

getFormWithID

public WebForm getFormWithID(String ID)
Returns the form found in this HTML segment with the specified ID.

Throws: SAXException thrown if there is an error parsing the segment.

getFormWithName

public WebForm getFormWithName(String name)
Returns the form found in this HTML segment with the specified name.

Throws: SAXException thrown if there is an error parsing the segment.

getImages

public WebImage[] getImages()
Returns the images found in the page in the order in which they appear.

Throws: SAXException thrown if there is an error parsing the segment.

getImageWithAltText

public WebImage getImageWithAltText(String source)
Returns the first image found in the page with the specified alt attribute.

Throws: SAXException thrown if there is an error parsing the segment.

getImageWithName

public WebImage getImageWithName(String name)
Returns the image found in the page with the specified name.

Throws: SAXException thrown if there is an error parsing the segment.

getImageWithSource

public WebImage getImageWithSource(String source)
Returns the first image found in the page with the specified src attribute.

Throws: SAXException thrown if there is an error parsing the segment.

getLinks

public WebLink[] getLinks()
Returns the links found in this HTML segment in the order in which they appear.

Throws: SAXException thrown if there is an error parsing the segment.

getLinkWith

public WebLink getLinkWith(String text)
Returns the first link which contains the specified text.

Throws: SAXException thrown if there is an error parsing the segment.

getLinkWithImageText

public WebLink getLinkWithImageText(String text)
Returns the first link which contains an image with the specified text as its 'alt' attribute.

Throws: SAXException thrown if there is an error parsing the segment.

getMatchingForms

public WebForm[] getMatchingForms(HTMLElementPredicate predicate, Object criteria)
Returns all forms found in the page matching the specified criteria.

Throws: SAXException thrown if there is an error parsing the response.

getMatchingLinks

public WebLink[] getMatchingLinks(HTMLElementPredicate predicate, Object criteria)
Returns all links found in the page matching the specified criteria.

Throws: SAXException thrown if there is an error parsing the response.

getMatchingTables

public WebTable[] getMatchingTables(HTMLElementPredicate predicate, Object criteria)
Returns all tables found in the page matching the specified criteria.

Throws: SAXException thrown if there is an error parsing the response.

getTables

public WebTable[] getTables()
Returns the top-level tables found in this HTML segment in the order in which they appear.

Throws: SAXException thrown if there is an error parsing the segment.

getTableStartingWith

public WebTable getTableStartingWith(String text)
Returns the first table in this HTML segment which has the specified text as the full text of its first non-blank row and non-blank column. Will recurse into any nested tables, as needed.

Returns: the selected table, or null if none is found

Throws: SAXException thrown if there is an error parsing the segment.

getTableStartingWithPrefix

public WebTable getTableStartingWithPrefix(String text)
Returns the first table in this HTML segment which has the specified text as a prefix of the text in its first non-blank row and non-blank column. Will recurse into any nested tables, as needed.

Returns: the selected table, or null if none is found

Throws: SAXException thrown if there is an error parsing the segment.

getTableWithID

public WebTable getTableWithID(String ID)
Returns the first table in this HTML segment which has the specified text as its ID attribute. Will recurse into any nested tables, as needed.

Returns: the selected table, or null if none is found

Throws: SAXException thrown if there is an error parsing the segment.

getTableWithSummary

public WebTable getTableWithSummary(String summary)
Returns the first table in this HTML segment which has the specified text as its summary attribute. Will recurse into any nested tables, as needed.

Returns: the selected table, or null if none is found

Throws: SAXException thrown if there is an error parsing the segment.

getTextBlocks

public TextBlock[] getTextBlocks()
Returns the top-level block elements found in the page in the order in which they appear.

Throws: SAXException thrown if there is an error parsing the segment.

Since: 1.6