Created
February 4, 2012 20:22
-
-
Save webdevwilson/1739887 to your computer and use it in GitHub Desktop.
HtmlUnit getting started
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// from HtmlUnit getting started | |
final WebClient webClient = new WebClient(); | |
final HtmlPage page = webClient.getPage("http://htmlunit.sourceforge.net"); | |
final DOMNodeSelector cssSelector = new DOMNodeSelector(page.getDocumentElement()); | |
final Set elements = cssSelector.querySelectorAll("div.section h2"); | |
final Node first = elements.iterator().next(); | |
assertThat(first.getTextContent(), equalTo("HtmlUnit")); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment