mirror of
https://github.com/spring-projects/spring-petclinic.git
synced 2025-07-17 21:15:50 +00:00
Add an extra wait and mostly fixed the addVisit test
This commit is contained in:
parent
cc80b74825
commit
6a85a1ac63
3 changed files with 23 additions and 16 deletions
|
@ -41,6 +41,7 @@ public class AddOwnerIT extends SeleniumBaseIT {
|
||||||
new Select(driver.findElement(By.name("type"))).selectByValue("hamster");
|
new Select(driver.findElement(By.name("type"))).selectByValue("hamster");
|
||||||
driver.findElement(By.name("name")).submit();
|
driver.findElement(By.name("name")).submit();
|
||||||
|
|
||||||
|
waitFor(new FixedPeriod(1000));
|
||||||
waitForPageToLoad();
|
waitForPageToLoad();
|
||||||
Assert.assertTrue(pageContainsText("Thumper"));
|
Assert.assertTrue(pageContainsText("Thumper"));
|
||||||
setTestFinished();
|
setTestFinished();
|
||||||
|
|
|
@ -10,7 +10,7 @@ import java.net.MalformedURLException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Martijn
|
* @author Sophie
|
||||||
* @since 21-6-2017.
|
* @since 21-6-2017.
|
||||||
*/
|
*/
|
||||||
public class AddVisitIT extends SeleniumBaseIT {
|
public class AddVisitIT extends SeleniumBaseIT {
|
||||||
|
@ -20,24 +20,29 @@ public class AddVisitIT extends SeleniumBaseIT {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Category(SeleniumBaseIT.class)
|
@Category(SeleniumBaseIT.class)
|
||||||
public void addOwnerTest() {
|
public void editPetNameAndAddAVisit() {
|
||||||
driver.findElement(By.name("lastName")).submit();
|
driver.get(BASE_URL+"/owners/find");
|
||||||
|
|
||||||
//Go to first owner
|
driver.findElement(By.name("lastName")).submit();
|
||||||
WebElement table = driver.findElement(By.tagName("table"));
|
|
||||||
List<WebElement> cells = table.findElements(By.xpath("tr/td"));
|
|
||||||
cells.get(0).findElement(By.xpath("a")).click();
|
|
||||||
|
|
||||||
//Go to edit page of first pet
|
//Go to first owner
|
||||||
driver.findElement(By.xpath("//table//tr/td/table/tbody//a[text()='Edit Pet']")).click();
|
WebElement table = driver.findElement(By.tagName("table"));
|
||||||
|
List<WebElement> cells = table.findElements(By.xpath(".//tr/td"));
|
||||||
|
cells.get(0).findElement(By.xpath("a")).click();
|
||||||
|
|
||||||
//Edit Name of pet
|
//Go to edit page of first pet
|
||||||
fillTextField(By.name("name"), "foobar");
|
driver.findElement(By.xpath("//table//tr/td/table/tbody//a[contains(text(),'Edit')]")).click();
|
||||||
driver.findElement(By.name("name")).submit();
|
|
||||||
|
|
||||||
waitForPageToLoad();
|
//Edit Name of pet
|
||||||
Assert.assertNotNull(driver.findElement(By.xpath("//table//tr/td/dl/dd/[contains(text(), 'foobar')]")));
|
fillTextField(By.name("name"), "foobar");
|
||||||
setTestFinished();
|
driver.findElement(By.name("name")).submit();
|
||||||
|
|
||||||
|
waitFor(new FixedPeriod(1000));
|
||||||
|
waitForPageToLoad();
|
||||||
|
Assert.assertNotNull(driver.findElement(By.xpath("//table//tr/td/dl/dd[contains(text(), 'foobar')]")));
|
||||||
|
|
||||||
|
//TODO add a visit
|
||||||
|
setTestFinished();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@ package nl.utwente.bpsd.selenium;
|
||||||
|
|
||||||
import org.junit.After;
|
import org.junit.After;
|
||||||
import org.openqa.selenium.*;
|
import org.openqa.selenium.*;
|
||||||
|
import org.openqa.selenium.chrome.ChromeDriver;
|
||||||
import org.openqa.selenium.remote.Augmenter;
|
import org.openqa.selenium.remote.Augmenter;
|
||||||
import org.openqa.selenium.remote.DesiredCapabilities;
|
import org.openqa.selenium.remote.DesiredCapabilities;
|
||||||
import org.openqa.selenium.remote.RemoteWebDriver;
|
import org.openqa.selenium.remote.RemoteWebDriver;
|
||||||
|
@ -20,8 +21,8 @@ import java.util.logging.Logger;
|
||||||
*/
|
*/
|
||||||
public class SeleniumBaseIT {
|
public class SeleniumBaseIT {
|
||||||
protected final WebDriver driver;
|
protected final WebDriver driver;
|
||||||
public static final String BASE_URL = "http://pet-clinic:8080/";
|
|
||||||
private boolean testFinished = false;
|
private boolean testFinished = false;
|
||||||
|
public static final String BASE_URL = "http://pet-clinic:8080/";
|
||||||
// public static final String BASE_URL = "http://localhost:8080/";
|
// public static final String BASE_URL = "http://localhost:8080/";
|
||||||
|
|
||||||
public SeleniumBaseIT() throws MalformedURLException {
|
public SeleniumBaseIT() throws MalformedURLException {
|
||||||
|
|
Loading…
Reference in a new issue