Hi again,
it seems to me, that the method HtmlPage.getAnchors() does not return
all anchors that are actually available in the page. Maybe I made a bad
mistake in my code, but I don't think so ;) Actually my code is based
on a piece of code that was posted here earlier. That is my version:
private HtmlAnchor getHtmlAnchor(String label) {
List returnedAnchors = _page.getAnchors();
Iterator i = returnedAnchors.iterator();
HtmlAnchor anchor = null;
while(i.hasNext()) {
//some debug output
_logger.displayProgressInfo("DebugInfo: " +
((HtmlAnchor)i.next()).toString());
if (label.equals(((HtmlAnchor)i.next()).asText())) {
anchor = (HtmlAnchor)i.next();
}
}
return anchor;
}
And this is the HTML-Code I tested with:
<html>
<head>
<title>Link Test Page</title>
</head>
<body>
Here are some Links!
<a href="blubb">Blubb</a>
<a href="http://www.heise.de" target="_blank">Heise Ticker</a>
<a href="mailto:th...@cy..." title="Mail to
Thomas">E-Mail</a>
</body>
</html>
HtmlPage.getAnchors() returns only 2 of these 3 given anchors. In other
samples I have seen much worse variations.
I use HmtlUnit 1.1 with updated commons-httpclient (Alpha 2 I think).
kind regards,
Thomas
Berlin
|