Commit e9b3f89d authored by Reiner Jung's avatar Reiner Jung

remove BabsieWebTest as it is already part of the BasbiWeb project

parent 23b5f9cd
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>BabsiApp Test</name>
<name>BabsiAppTest</name>
<comment></comment>
<projects>
<project>BabsiApp</project>
......
package cau.swp.babsi.gui;
import java.util.regex.Pattern;
import java.util.concurrent.TimeUnit;
import org.hamcrest.core.IsEqual;
import org.junit.*;
import static org.junit.Assert.*;
import static org.hamcrest.CoreMatchers.*;
import org.openqa.selenium.*;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.support.ui.Select;
import com.sun.jna.StringArray;
/**
* Testet Das Anlegen, Löschen und die Navigation im Menü von Stationen, Interventionen, Infektionen und Antibiotika
* @author cDor
*
*/
public class GUIAddElementTest {
private WebDriver driver;
private String baseUrl;
private boolean acceptNextAlert = true;
private StringBuffer verificationErrors = new StringBuffer();
private String[] objectStrings;
@Before
public void setUp() throws Exception {
driver = new FirefoxDriver();
baseUrl = GUITestData.baseUrl;
objectStrings = new String[4];
objectStrings[0] = "Antibiotika";
objectStrings[1] = "Stationen";
objectStrings[2] = "Infektionen";
objectStrings[3] = "Interventionen";
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
}
@Test
public void testGUIAddElementTest() throws Exception {
driver.get(baseUrl + "babsi");
//Login
driver.findElement(By.name("username")).clear();
driver.findElement(By.name("username")).sendKeys("user123");
driver.findElement(By.name("password")).clear();
driver.findElement(By.name("password")).sendKeys("password");
driver.findElement(By.cssSelector("input[type=\"submit\"]")).click();
for(int i=0;i<objectStrings.length;i++){
//Teste Navigation
driver.findElement(By.linkText(objectStrings[i])).click();
assertEquals(objectStrings[i]+" �bersicht", driver.getTitle());
driver.findElement(By.linkText("Dashboard")).click();
try {
assertEquals("Dashboard", driver.findElement(By.cssSelector("div.panel-heading")).getText());
} catch (Error e) {
verificationErrors.append(e.toString());
}
driver.findElement(By.linkText(objectStrings[i])).click();
driver.findElement(By.linkText(objectStrings[i]+" anlegen")).click();
assertEquals(objectStrings[i]+" anlegen", driver.getTitle());
driver.findElement(By.linkText(objectStrings[i]+" �bersicht")).click();
try {
assertEquals(objectStrings[i]+" �bersicht", driver.findElement(By.cssSelector("h1")).getText());
} catch (Error e) {
verificationErrors.append(e.toString());
}
//Teste anlegen
driver.findElement(By.linkText(objectStrings[i]+" anlegen")).click();
driver.findElement(By.id("name")).clear();
driver.findElement(By.id("name")).sendKeys("AnlegeTest10");
driver.findElement(By.id("create")).click();
try {
assertEquals(objectStrings[i]+" anzeigen", driver.findElement(By.cssSelector("h1")).getText());
} catch (Error e) {
verificationErrors.append(e.toString());
}
try {
assertEquals("AnlegeTest10", driver.findElement(By.cssSelector("span.property-value")).getText());
} catch (Error e) {
verificationErrors.append(e.toString());
}
//Teste bearbeiten
driver.findElement(By.linkText("Bearbeiten")).click();
driver.findElement(By.id("name")).clear();
driver.findElement(By.id("name")).sendKeys("AnlegeTest11");
try {
assertEquals(objectStrings[i]+" bearbeiten", driver.findElement(By.cssSelector("h1")).getText());
} catch (Error e) {
verificationErrors.append(e.toString());
}
driver.findElement(By.name("_action_update")).click();
try {
assertEquals(objectStrings[i]+" anzeigen", driver.findElement(By.cssSelector("h1")).getText());
} catch (Error e) {
verificationErrors.append(e.toString());
}
try {
assertEquals("AnlegeTest11", driver.findElement(By.cssSelector("span.property-value")).getText());
} catch (Error e) {
verificationErrors.append(e.toString());
}
//Teste l�schen
driver.findElement(By.name("_action_delete")).click();
assertTrue(closeAlertAndGetItsText().matches("^Sind Sie sicher[\\s\\S]$"));
try {
assertEquals(objectStrings[i]+" �bersicht", driver.getTitle());
} catch (Error e) {
verificationErrors.append(e.toString());
}
//Teste anlegen und finden in der �bersicht
driver.findElement(By.linkText(objectStrings[i]+" anlegen")).click();
driver.findElement(By.id("name")).clear();
driver.findElement(By.id("name")).sendKeys("AnlegeTest30");
driver.findElement(By.id("create")).click();
driver.findElement(By.linkText(objectStrings[i]+" anlegen")).click();
try {
assertEquals(objectStrings[i]+" anlegen", driver.findElement(By.cssSelector("h1")).getText());
} catch (Error e) {
verificationErrors.append(e.toString());
}
driver.findElement(By.linkText(objectStrings[i]+" �bersicht")).click();
//Ist es nicht auf der ersten Seite, dann auf der n�chsten
while(driver.findElements(By.linkText("AnlegeTest30")).isEmpty()) {
driver.findElement(By.linkText("N�chste")).click();
}
//L�sche das Element wieder
driver.findElement(By.linkText("AnlegeTest30")).click();
driver.findElement(By.name("_action_delete")).click();
assertTrue(closeAlertAndGetItsText().matches("^Sind Sie sicher[\\s\\S]$"));
try {
assertEquals(objectStrings[i]+" �bersicht", driver.findElement(By.cssSelector("h1")).getText());
} catch (Error e) {
verificationErrors.append(e.toString());
}
driver.findElement(By.linkText("Dashboard")).click();
try {
assertEquals("Dashboard", driver.getTitle());
} catch (Error e) {
verificationErrors.append(e.toString());
}
}
}
@After
public void tearDown() throws Exception {
driver.quit();
String verificationErrorString = verificationErrors.toString();
if (!"".equals(verificationErrorString)) {
fail(verificationErrorString);
}
}
private boolean isElementPresent(By by) {
try {
driver.findElement(by);
return true;
} catch (NoSuchElementException e) {
return false;
}
}
private boolean isAlertPresent() {
try {
driver.switchTo().alert();
return true;
} catch (NoAlertPresentException e) {
return false;
}
}
private String closeAlertAndGetItsText() {
try {
Alert alert = driver.switchTo().alert();
String alertText = alert.getText();
if (acceptNextAlert) {
alert.accept();
} else {
alert.dismiss();
}
return alertText;
} finally {
acceptNextAlert = true;
}
}
}
package cau.swp.babsi.gui;
import java.util.regex.Pattern;
import java.util.concurrent.TimeUnit;
import org.junit.*;
import static org.junit.Assert.*;
import static org.hamcrest.CoreMatchers.*;
import org.openqa.selenium.*;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.support.ui.Select;
public class GUIBenutzerVerwaltung {
private WebDriver driver;
private String baseUrl;
private boolean acceptNextAlert = true;
private StringBuffer verificationErrors = new StringBuffer();
@Before
public void setUp() throws Exception {
driver = new FirefoxDriver();
baseUrl = GUITestData.baseUrl;
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
}
@Test
public void testGUIBenutzerAnlegen() throws Exception {
driver.get(baseUrl + "babsi/user/list");
//Login
driver.findElement(By.name("username")).clear();
driver.findElement(By.name("username")).sendKeys("user123");
driver.findElement(By.name("password")).clear();
driver.findElement(By.name("password")).sendKeys("password");
driver.findElement(By.cssSelector("input[type=\"submit\"]")).click();
try {
assertEquals("Benutzer �bersicht", driver.getTitle());
} catch (Error e) {
verificationErrors.append(e.toString());
}
driver.findElement(By.linkText("Benutzer anlegen")).click();
driver.findElement(By.id("username")).sendKeys("Maria");
driver.findElement(By.id("pw1")).clear();
driver.findElement(By.id("pw1")).sendKeys("bananashake");
driver.findElement(By.id("pw2")).clear();
driver.findElement(By.id("pw2")).sendKeys("bananashake");
driver.findElement(By.id("create")).click();
try {
assertEquals("Benutzer anzeigen", driver.getTitle());
} catch (Error e) {
verificationErrors.append(e.toString());
}
//Benutzer unique, dies ist die �berpr�fung
driver.get(baseUrl + "babsi/user/list");
try {
assertEquals("Benutzer �bersicht", driver.getTitle());
} catch (Error e) {
verificationErrors.append(e.toString());
}
driver.findElement(By.linkText("Benutzer anlegen")).click();
driver.findElement(By.id("username")).sendKeys("Maria");
driver.findElement(By.id("pw1")).clear();
driver.findElement(By.id("pw1")).sendKeys("bananenshake");
driver.findElement(By.id("pw2")).clear();
driver.findElement(By.id("pw2")).sendKeys("bananenshake");
driver.findElement(By.id("create")).click();
try {
assertEquals("Die Eigenschaft [Benutzername] des Typs [Benutzer] mit dem Wert [Maria] darf nur einmal vorkommen", driver.findElement(By.cssSelector("ul.errors > li")).getText());
} catch (Error e) {
verificationErrors.append(e.toString());
}
//Benutzer �ndern
driver.get(baseUrl + "babsi/user/list");
try {
assertEquals("Benutzer �bersicht", driver.getTitle());
} catch (Error e) {
verificationErrors.append(e.toString());
}
driver.findElement(By.linkText("Maria")).click();
try {
assertEquals("Benutzer anzeigen", driver.getTitle());
} catch (Error e) {
verificationErrors.append(e.toString());
}
driver.findElement(By.linkText("Bearbeiten")).click();
driver.findElement(By.id("username")).clear();
driver.findElement(By.id("username")).sendKeys("Anna");
driver.findElement(By.id("pw1")).clear();
driver.findElement(By.id("pw1")).sendKeys("bananashake");
driver.findElement(By.id("pw2")).clear();
driver.findElement(By.id("pw2")).sendKeys("bananashake");
driver.findElement(By.name("_action_update")).click();
try {
assertTrue(isElementPresent(By.cssSelector("div.message")));
} catch (Error e) {
verificationErrors.append(e.toString());
}
//Benutzer l�schen
driver.get(baseUrl + "babsi/user/list");
try {
assertEquals("Benutzer �bersicht", driver.getTitle());
} catch (Error e) {
verificationErrors.append(e.toString());
}
driver.findElement(By.linkText("Anna")).click();
try {
assertEquals("Benutzer anzeigen", driver.getTitle());
} catch (Error e) {
verificationErrors.append(e.toString());
}
driver.findElement(By.name("_action_delete")).click();
assertTrue(closeAlertAndGetItsText().matches("^Sind Sie sicher[\\s\\S]$"));
}
@After
public void tearDown() throws Exception {
driver.quit();
String verificationErrorString = verificationErrors.toString();
if (!"".equals(verificationErrorString)) {
fail(verificationErrorString);
}
}
private boolean isElementPresent(By by) {
try {
driver.findElement(by);
return true;
} catch (NoSuchElementException e) {
return false;
}
}
private boolean isAlertPresent() {
try {
driver.switchTo().alert();
return true;
} catch (NoAlertPresentException e) {
return false;
}
}
private String closeAlertAndGetItsText() {
try {
Alert alert = driver.switchTo().alert();
String alertText = alert.getText();
if (acceptNextAlert) {
alert.accept();
} else {
alert.dismiss();
}
return alertText;
} finally {
acceptNextAlert = true;
}
}
}
package cau.swp.babsi.gui;
import java.util.regex.Pattern;
import java.util.concurrent.TimeUnit;
import org.junit.*;
import static org.junit.Assert.*;
import static org.hamcrest.CoreMatchers.*;
import org.openqa.selenium.*;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.support.ui.Select;
public class GUIBenutzerÜbersicht {
private WebDriver driver;
private String baseUrl;
private boolean acceptNextAlert = true;
private StringBuffer verificationErrors = new StringBuffer();
@Before
public void setUp() throws Exception {
driver = new FirefoxDriver();
baseUrl = GUITestData.baseUrl;
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
}
@Test
public void testGUIBenutzerÜbersicht() throws Exception {
driver.get(baseUrl + "babsi/");
//Login
driver.findElement(By.name("username")).clear();
driver.findElement(By.name("username")).sendKeys("user123");
driver.findElement(By.name("password")).clear();
driver.findElement(By.name("password")).sendKeys("password");
driver.findElement(By.cssSelector("input[type=\"submit\"]")).click();
driver.findElement(By.linkText("Benutzer")).click();
try {
assertEquals("Benutzer �bersicht", driver.getTitle());
} catch (Error e) {
verificationErrors.append(e.toString());
}
}
@After
public void tearDown() throws Exception {
driver.quit();
String verificationErrorString = verificationErrors.toString();
if (!"".equals(verificationErrorString)) {
fail(verificationErrorString);
}
}
private boolean isElementPresent(By by) {
try {
driver.findElement(by);
return true;
} catch (NoSuchElementException e) {
return false;
}
}
private boolean isAlertPresent() {
try {
driver.switchTo().alert();
return true;
} catch (NoAlertPresentException e) {
return false;
}
}
private String closeAlertAndGetItsText() {
try {
Alert alert = driver.switchTo().alert();
String alertText = alert.getText();
if (acceptNextAlert) {
alert.accept();
} else {
alert.dismiss();
}
return alertText;
} finally {
acceptNextAlert = true;
}
}
}
package cau.swp.babsi.gui;
import java.util.regex.Pattern;
import java.util.concurrent.TimeUnit;
import org.junit.*;
import static org.junit.Assert.*;
import static org.hamcrest.CoreMatchers.*;
import org.openqa.selenium.*;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.support.ui.Select;
public class GUIChecklistenanzeigen {
private WebDriver driver;
private String baseUrl;
private boolean acceptNextAlert = true;
private StringBuffer verificationErrors = new StringBuffer();
@Before
public void setUp() throws Exception {
driver = new FirefoxDriver();
baseUrl = GUITestData.baseUrl;
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
}
@Test
public void testGUIChecklistenanzeigen() throws Exception {
driver.get(baseUrl + "babsi/");
//Login
driver.findElement(By.name("username")).clear();
driver.findElement(By.name("username")).sendKeys("user123");
driver.findElement(By.name("password")).clear();
driver.findElement(By.name("password")).sendKeys("password");
driver.findElement(By.cssSelector("input[type=\"submit\"]")).click();
driver.findElement(By.linkText("Checklisten")).click();
try {
assertEquals("Checklisten �bersicht", driver.getTitle());
} catch (Error e) {
verificationErrors.append(e.toString());
}
}
@After
public void tearDown() throws Exception {
driver.quit();
String verificationErrorString = verificationErrors.toString();
if (!"".equals(verificationErrorString)) {
fail(verificationErrorString);
}
}
private boolean isElementPresent(By by) {
try {
driver.findElement(by);
return true;
} catch (NoSuchElementException e) {
return false;
}
}
private boolean isAlertPresent() {
try {
driver.switchTo().alert();
return true;
} catch (NoAlertPresentException e) {
return false;
}
}
private String closeAlertAndGetItsText() {
try {
Alert alert = driver.switchTo().alert();
String alertText = alert.getText();
if (acceptNextAlert) {
alert.accept();
} else {
alert.dismiss();
}
return alertText;
} finally {
acceptNextAlert = true;
}
}
}
package cau.swp.babsi.gui;
import java.util.regex.Pattern;
import java.util.concurrent.TimeUnit;
import org.junit.*;
import static org.junit.Assert.*;
import static org.hamcrest.CoreMatchers.*;
import org.openqa.selenium.*;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.support.ui.Select;
public class GUIExport {
private WebDriver driver;
private String baseUrl;
private boolean acceptNextAlert = true;
private StringBuffer verificationErrors = new StringBuffer();
@Before
public void setUp() throws Exception {
driver = new FirefoxDriver();
baseUrl = GUITestData.baseUrl;
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
}
@Test
public void testGUIExport() throws Exception {
driver.get(baseUrl + "babsi/");
//Login
driver.findElement(By.name("username")).clear();
driver.findElement(By.name("username")).sendKeys("user123");
driver.findElement(By.name("password")).clear();
driver.findElement(By.name("password")).sendKeys("password");
driver.findElement(By.cssSelector("input[type=\"submit\"]")).click();