mirror of
https://github.com/spring-projects/spring-petclinic.git
synced 2025-07-17 21:15:50 +00:00
Add an extra wait
This commit is contained in:
parent
c4dd55342d
commit
cc80b74825
2 changed files with 21 additions and 1 deletions
|
@ -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();
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue