以下のコード スニペットは正常に動作しますが、次のwait.until()
行に少し問題があります。
wait.until(new ElementPresent(By.xpath("//a[@title='Go to Google Home']")));
PageFactory
WebElement
homePageLink
動作しますが、代わりに送信したい:
wait.until(new ElementPresent(homePageLink));
それを行う方法はありますか?
これらの新しい Selenium 2 の機能については、少し頭が混乱してしまい、多くのドキュメントを見つけることができません。
ありがとう。
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<WebElement> {
private final By locator;
public ElementPresent(By locator) {
this.locator = locator;
}
public WebElement apply(WebDriver driver) {
return driver.findElement(locator);
}
}