Friday, 10 February 2012

how to find out the anchor text in htmlunit


we can use the asText() method to find out the anchor text associated with an anchor using htmlunit.

e.g.
HtmlAnchor anc=(HtmlAnchor)page.getByXpath("//a").get(0);
System.out.println("Anchor Text " +anc.asText());

1 comment: