Add an extra wait

This commit is contained in:
Marty30 2017-06-25 14:03:14 +02:00
parent c4dd55342d
commit cc80b74825
2 changed files with 21 additions and 1 deletions

View file

@ -23,6 +23,7 @@ public class FindOwnerIT extends SeleniumBaseIT {
driver.get(BASE_URL+"/owners/find");
fillTextField(By.name("lastName"),"Coleman");
driver.findElement(By.name("lastName")).submit();
waitFor(new FixedPeriod(1000));
waitForPageToLoad();
Assert.assertTrue("Could not find \"Jean Coleman\" on the current page. This is the html of the current page: "+getHTML(),driver.findElements(By.xpath("//*[text()='Jean Coleman']")).size() == 1);
setTestFinished();

View file

@ -64,7 +64,7 @@ public class SeleniumBaseIT {
waitFor(new PageLoadedExpectedCondition());
}
private void waitFor(ExpectedCondition<Boolean> condition) {
protected void waitFor(ExpectedCondition<Boolean> condition) {
new WebDriverWait(driver, 3).until(condition);
}
@ -78,4 +78,23 @@ public class SeleniumBaseIT {
throw new ClassCastException("This webdriver is not able to execute javascript.");
}
}
protected class FixedPeriod implements ExpectedCondition<Boolean> {
private final int time;
public FixedPeriod(int timeInMilliseconds) {
this.time = timeInMilliseconds;
}
@Override
public Boolean apply(WebDriver webDriver) {
try {
Thread.sleep(time);
return true;
} catch (InterruptedException e) {
e.printStackTrace();
return false;
}
}
}
}