1. public class GoogleResultsPage extends TestBase {
  2.  
  3. @FindBy(xpath = "//a[@title='Go to Google Home']")
  4. @CacheLookup
  5. private WebElement homePageLink;
  6.  
  7. public GoogleResultsPage() {
  8. wait.until(new ElementPresent(By.xpath("//a[@title='Go to Google Home']")));
  9. assertThat(driver.getTitle(), containsString("Google Search"));
  10. }
  11.  
  12. public String getSearchLinkText(int index) {
  13. return driver.findElement(By.xpath("//h3[@class='r']//a[@href]["+index+"]")).getText();
  14. }
  15. }
  16.  
  17.  
  18. public class ElementPresent implements ExpectedCondition<WebElement> {
  19. private final By locator;
  20.  
  21. public ElementPresent(By locator) {
  22. this.locator = locator;
  23. }
  24.  
  25. public WebElement apply(WebDriver driver) {
  26. return driver.findElement(locator);
  27. }
  28. }