Skip to content
rwallace edited this page Sep 13, 2010 · 2 revisions

I’m tired of XPath. It’s ugly and clunky and can be hard to remember all the right syntax. It’s a lot of baggage to carry around when you’re trying to write integration tests. CSS is a much simpler, easier to understand language for selecting elements from a document and using it in integration tests doesn’t require a huge context switch from writing document queries for jQuery or Dojo or other javascript frameworks that use CSS selectors to find elements to operate on.

We aim to provide full support for the CSS3 selectors spec and may add some additional sugar for traversing documents similar to what jQuery provides javascript authors.

Example:


import static com.threelevers.css.Selector.from;

// other imports omitted

public class WebAppTest {
@Test
public void assertThatDefaultDashboardContainsExpectedPortlets() {
WebClient webClient = new WebClient();
Document dashboard = webClient.getPage(“http://localhost:8080”);
Iterable portlets = from(dashboard).select(“.portlet .title”);
// make assertions about the portlet titles being correct
}
}

Clone this wiki locally