Skip to content
Snippets Groups Projects
Commit fa5f9ea1 authored by Matthew Williams's avatar Matthew Williams
Browse files

Add further selenium tests for deactivate, activate, and restructure tests

parent c7066c11
No related branches found
No related tags found
1 merge request!22Merge UC92 into Master
package edu.ncsu.csc.itrust.selenium;
import java.util.concurrent.TimeUnit;
import org.junit.*;
import org.openqa.selenium.*;
import org.openqa.selenium.htmlunit.HtmlUnitDriver;
public class ActivatePatientTest extends iTrustSeleniumTest {
private WebDriver driver;
private StringBuffer verificationErrors = new StringBuffer();
@Before
public void setUp() throws Exception {
super.setUp();
gen.standardData();
gen.patient92();
driver = new HtmlUnitDriver();
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
}
@Test
public void testActivatePreregisteredPatient() throws Exception {
HtmlUnitDriver driver = (HtmlUnitDriver)login("9000000000", "pw");
// Make sure we were able to log in
assertEquals("iTrust - HCP Home", driver.getTitle());
driver.findElement(By.cssSelector("h2.panel-title")).click();
driver.findElement(By.linkText("View Pre-Registered Patients")).click();
String text = driver.findElement(By.cssSelector("table.fTable")).getText();
// Make sure the preregistered patients show up in the preregistered patients list
assertTrue("Text not found!", text.contains("Brittany Franco"));
assertTrue("Text not found!", text.contains("1333 Who Cares Road Suite 102"));
assertTrue("Text not found!", text.contains("Raleigh NC"));
assertTrue("Text not found!", text.contains("brfranco@gmail.com"));
// Ensure we can click on the patient and see more details
driver.findElement(By.linkText("Brittany Franco")).click();
text = driver.findElement(By.cssSelector("table.fTable")).getText();
assertTrue("Text not found!", text.contains("Phone:919-971-0000"));
assertTrue("Text not found!", text.contains("Email:brfranco@gmail.com"));
assertTrue("Text not found!", text.contains("Address: 1333 Who Cares Road"));
// Activate the preregistered patient
driver.findElement(By.linkText("Activate")).click();
text = driver.findElement(By.cssSelector("table.fTable")).getText();
assertTrue("Text not found!", text.contains("type \"I UNDERSTAND\" into the box below and click the button"));
driver.findElement(By.name("understand")).sendKeys("I UNDERSTAND");
driver.findElement(By.name("action")).click();
// Ensure the patient gets the fully activated screen
text = driver.findElement(By.cssSelector("span.iTrustMessage")).getText();
assertTrue("Text not found!", text.contains("Patient Successfully Activated!"));
}
@After
public void tearDown() throws Exception {
driver.quit();
String verificationErrorString = verificationErrors.toString();
if (!"".equals(verificationErrorString)) {
fail(verificationErrorString);
}
}
}
package edu.ncsu.csc.itrust.selenium;
import java.util.concurrent.TimeUnit;
import org.junit.*;
import org.openqa.selenium.*;
import org.openqa.selenium.htmlunit.HtmlUnitDriver;
import com.gargoylesoftware.htmlunit.WebClient;
public class DeactivatePatientTest extends iTrustSeleniumTest {
private WebDriver driver;
private StringBuffer verificationErrors = new StringBuffer();
@Before
public void setUp() throws Exception {
super.setUp();
gen.standardData();
gen.patient92();
driver = new HtmlUnitDriver();
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
}
@Test
public void testDeactivatePatients() throws Exception {
HtmlUnitDriver driver = (HtmlUnitDriver)login("9000000000", "pw");
// Make sure we were able to log in
assertEquals("iTrust - HCP Home", driver.getTitle());
driver.findElement(By.cssSelector("h2.panel-title")).click();
driver.findElement(By.linkText("View Pre-Registered Patients")).click();
driver.findElement(By.cssSelector("input.deactivate")).click();
// Deactivate the specified patient
driver.findElement(By.name("understand")).sendKeys("I UNDERSTAND");
driver.findElement(By.name("action")).click();
driver.findElement(By.cssSelector("h2.panel-title")).click();
driver.findElement(By.linkText("View Pre-Registered Patients")).click();
String text = driver.findElement(By.cssSelector("table.fTable")).getText();
// Ensure the deactivated patient is no longer in the preregistered patients list
assertFalse("Text found, but shouldn't be!", text.contains("Brittany Franco"));
assertFalse("Text found, but shouldn't be!", text.contains("1333 Who Cares Road Suite 102"));
assertFalse("Text found, but shouldn't be!", text.contains("Raleigh NC"));
assertFalse("Text found, but shouldn't be!", text.contains("brfranco@gmail.com"));
}
@Test
public void testLoginAfterPatientDeactivated() throws Exception {
HtmlUnitDriver driver = (HtmlUnitDriver)login("9000000000", "pw");
// Make sure we were able to log in
assertEquals("iTrust - HCP Home", driver.getTitle());
driver.findElement(By.cssSelector("h2.panel-title")).click();
driver.findElement(By.linkText("View Pre-Registered Patients")).click();
driver.findElement(By.cssSelector("input.deactivate")).click();
// Deactivate the specified patient
driver.findElement(By.name("understand")).sendKeys("I UNDERSTAND");
driver.findElement(By.name("action")).click();
driver.findElement(By.cssSelector("h2.panel-title")).click();
driver.findElement(By.linkText("View Pre-Registered Patients")).click();
String text = driver.findElement(By.cssSelector("table.fTable")).getText();
// Make sure deactivated patient doesn't show up in preregistered list
assertFalse("Text found, but shouldn't be!", text.contains("Brittany Franco"));
assertFalse("Text found, but shouldn't be!", text.contains("1333 Who Cares Road Suite 102"));
assertFalse("Text found, but shouldn't be!", text.contains("Raleigh NC"));
assertFalse("Text found, but shouldn't be!", text.contains("brfranco@gmail.com"));
// Test if the deactivated patient can log in
HtmlUnitDriver patientDriver = (HtmlUnitDriver)login("92", "pw");
assertEquals("Server Rebooted", patientDriver.getTitle());
text = patientDriver.findElement(By.xpath("//body")).getText();
assertTrue("Text not found!", text.contains("Authorization Error!"));
assertTrue("Text not found!", text.contains("You are not allowed to access this page"));
assertTrue("Text not found!", text.contains("Log back in."));
}
@After
public void tearDown() throws Exception {
driver.quit();
String verificationErrorString = verificationErrors.toString();
if (!"".equals(verificationErrorString)) {
fail(verificationErrorString);
}
}
}
......@@ -32,54 +32,13 @@ public class ViewAllPreregisteredPatientsTest extends iTrustSeleniumTest {
driver.findElement(By.linkText("View Pre-Registered Patients")).click();
String text = driver.findElement(By.cssSelector("table.fTable")).getText();
// Make sure the preregistered patients are shown in the list
assertTrue("Text not found!", text.contains("Brittany Franco"));
assertTrue("Text not found!", text.contains("1333 Who Cares Road Suite 102"));
assertTrue("Text not found!", text.contains("Raleigh NC"));
assertTrue("Text not found!", text.contains("brfranco@gmail.com"));
}
@Test
public void testDeactivatePatients() throws Exception {
HtmlUnitDriver driver = (HtmlUnitDriver)login("9000000000", "pw");
// Make sure we were able to log in
assertEquals("iTrust - HCP Home", driver.getTitle());
driver.findElement(By.cssSelector("h2.panel-title")).click();
driver.findElement(By.linkText("View Pre-Registered Patients")).click();
driver.findElement(By.cssSelector("input.deactivate")).click();
}
@Test
public void testActivatePreregisteredPatient() throws Exception {
HtmlUnitDriver driver = (HtmlUnitDriver)login("9000000000", "pw");
// Make sure we were able to log in
assertEquals("iTrust - HCP Home", driver.getTitle());
driver.findElement(By.cssSelector("h2.panel-title")).click();
driver.findElement(By.linkText("View Pre-Registered Patients")).click();
String text = driver.findElement(By.cssSelector("table.fTable")).getText();
assertTrue("Text not found!", text.contains("Brittany Franco"));
assertTrue("Text not found!", text.contains("1333 Who Cares Road Suite 102"));
assertTrue("Text not found!", text.contains("Raleigh NC"));
assertTrue("Text not found!", text.contains("brfranco@gmail.com"));
driver.findElement(By.linkText("Brittany Franco")).click();
text = driver.findElement(By.cssSelector("table.fTable")).getText();
assertTrue("Text not found!", text.contains("Phone:919-971-0000"));
assertTrue("Text not found!", text.contains("Email:brfranco@gmail.com"));
assertTrue("Text not found!", text.contains("Address: 1333 Who Cares Road"));
driver.findElement(By.linkText("Activate")).click();
text = driver.findElement(By.cssSelector("table.fTable")).getText();
assertTrue("Text not found!", text.contains("type \"I UNDERSTAND\" into the box below and click the button"));
driver.findElement(By.name("understand")).sendKeys("I UNDERSTAND");
driver.findElement(By.name("action")).click();
text = driver.findElement(By.cssSelector("span.iTrustMessage")).getText();
assertTrue("Text not found!", text.contains("Patient Successfully Activated!"));
}
@After
public void tearDown() throws Exception {
driver.quit();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment