Add an extra wait and mostly fixed the addVisit test

This commit is contained in:
Marty30 2017-06-25 15:02:35 +02:00
parent cc80b74825
commit 6a85a1ac63
3 changed files with 23 additions and 16 deletions

View file

@ -41,6 +41,7 @@ public class AddOwnerIT extends SeleniumBaseIT {
new Select(driver.findElement(By.name("type"))).selectByValue("hamster");
driver.findElement(By.name("name")).submit();
waitFor(new FixedPeriod(1000));
waitForPageToLoad();
Assert.assertTrue(pageContainsText("Thumper"));
setTestFinished();

View file

@ -10,7 +10,7 @@ import java.net.MalformedURLException;
import java.util.List;
/**
* @author Martijn
* @author Sophie
* @since 21-6-2017.
*/
public class AddVisitIT extends SeleniumBaseIT {
@ -20,24 +20,29 @@ public class AddVisitIT extends SeleniumBaseIT {
@Test
@Category(SeleniumBaseIT.class)
public void addOwnerTest() {
driver.findElement(By.name("lastName")).submit();
public void editPetNameAndAddAVisit() {
driver.get(BASE_URL+"/owners/find");
//Go to first owner
WebElement table = driver.findElement(By.tagName("table"));
List<WebElement> cells = table.findElements(By.xpath("tr/td"));
cells.get(0).findElement(By.xpath("a")).click();
driver.findElement(By.name("lastName")).submit();
//Go to edit page of first pet
driver.findElement(By.xpath("//table//tr/td/table/tbody//a[text()='Edit Pet']")).click();
//Go to first owner
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
fillTextField(By.name("name"), "foobar");
driver.findElement(By.name("name")).submit();
//Go to edit page of first pet
driver.findElement(By.xpath("//table//tr/td/table/tbody//a[contains(text(),'Edit')]")).click();
waitForPageToLoad();
Assert.assertNotNull(driver.findElement(By.xpath("//table//tr/td/dl/dd/[contains(text(), 'foobar')]")));
setTestFinished();
//Edit Name of pet
fillTextField(By.name("name"), "foobar");
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();
}
}

View file

@ -2,6 +2,7 @@ package nl.utwente.bpsd.selenium;
import org.junit.After;
import org.openqa.selenium.*;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.remote.Augmenter;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;
@ -20,8 +21,8 @@ import java.util.logging.Logger;
*/
public class SeleniumBaseIT {
protected final WebDriver driver;
public static final String BASE_URL = "http://pet-clinic:8080/";
private boolean testFinished = false;
public static final String BASE_URL = "http://pet-clinic:8080/";
// public static final String BASE_URL = "http://localhost:8080/";
public SeleniumBaseIT() throws MalformedURLException {