public class GoogleResultsPage extends TestBase {
@FindBy(xpath = "//a[@title='Go to Google Home']")
@CacheLookup
private WebElement homePageLink;
public GoogleResultsPage() {
wait.until(new ElementPresent(By.xpath("//a[@title='Go to Google Home']")));
assertThat(driver.getTitle(), containsString("Google Search"));
}
public String getSearchLinkText
(int index
) { return driver.findElement(By.xpath("//h3[@class='r']//a[@href]["+index+"]")).getText();
}
}
public class ElementPresent implements ExpectedCondition<WebElement> {
private final By locator;
public ElementPresent(By locator) {
this.locator = locator;
}
public WebElement apply(WebDriver driver) {
return driver.findElement(locator);
}
}