The code snippet below works fine, but having a little trouble with the wait.until() line.
wait.until(new ElementPresent(By.xpath("//a[@title='Go to Google Home']")));
It works but I want to send my PageFactory WebElement homePageLink instead.
How do I change my ElementPresent class to except both:
wait.until(new ElementPresent(By.xpath("//a[@title='Go to Google Home']"))); and wait.until(new ElementPresent(homePageLink));
Or is there better way? These new fangled selenium 2 features have got my head in a bit of a spin and I can't find much documentation.
Thanks.
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 class ElementPresent implements ExpectedCondition {
private final By locator;
public ElementPresent(By locator) {
this.locator = locator;
}
public WebElement apply(WebDriver driver) {
return driver.findElement(locator);
}
}