Skip to content

Instantly share code, notes, and snippets.

@beothorn
Created June 15, 2014 04:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save beothorn/cc945dbea51d1c200617 to your computer and use it in GitHub Desktop.
Save beothorn/cc945dbea51d1c200617 to your computer and use it in GitHub Desktop.
import webGrude.annotations.Page;
import webGrude.annotations.Selector;
import java.util.List;
public class PrintExampleSearchResults {
@Selector("")
public static class SearchResult{
@Selector(".result-title") public String resultTitle;
@Selector(".result-content") public String resultContent;
}
@Page("http://www.example.com/{0}")
public static class SearchResultPage {
@Selector("h1") public String header;
@Selector(".result") public List<SearchResult> searchResults;
}
public static void main(String... args){
SearchResultPage searchPage = Browser.open(SearchResultPage.class, "search term");
System.out.println(searchPage.header);
searchPage.searchResults.forEach(result ->
System.out.println("Title: "+result.resultTitle+"\n Content: "+result.resultContent)
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment