El siguiente fragmento de código funciona bien, pero estoy teniendo un pequeño problema con la línea wait.until()
:Cómo usar selenium 2 PageFactory init Elements con Wait.until()?
wait.until(new ElementPresent(By.xpath("//a[@title='Go to Google Home']")));
Funciona pero quiero enviar mi PageFactory
WebElement
homePageLink
lugar:
wait.until(new ElementPresent(homePageLink));
Es Hay alguna manera de hacer eso?
Estas nuevas características de Selenium 2 me han dado un vuelco y no encuentro mucha documentación.
Gracias.
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);
}
}
utilizo SlowLoadableComponent lugar. Me permite poner un retraso entre isLoaded() y load() para que la página siga reintentando hasta que se cargue la página. – djangofan