Created
February 4, 2012 18:53
-
-
Save webdevwilson/1739459 to your computer and use it in GitHub Desktop.
jquery HtmlUnit base class
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
public class WebTestBase { | |
protected WebClient webClient; | |
protected HtmlPage htmlPage; | |
protected void goTo(final String url){ | |
return (HtmlPage)webClient.getPage(url); | |
} | |
protected List $(final String cssSelector) { | |
final DOMNodeSelector cssSelector = new DOMNodeSelector(htmlPage.getDocumentElement()); | |
final Set nodes = cssSelector.querySelectorAll("div.section h2"); | |
// for some reason Set cannot be cast to Set? | |
final List elements = new ArrayList(nodes.size()); | |
for (final Node node : nodes) { | |
elements.add((HtmlElement)node); | |
} | |
return elements; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment